Update to ranch 2.0

This commit is contained in:
dcorbacho 2021-03-08 22:59:22 +01:00
parent 3755b5b03f
commit 61f7b2a723
55 changed files with 237 additions and 118 deletions

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -19,7 +19,7 @@
-behaviour(supervisor2). -behaviour(supervisor2).
-behaviour(ranch_protocol). -behaviour(ranch_protocol).
-export([start_link/4, reader/1]). -export([start_link/3, reader/1]).
-export([init/1]). -export([init/1]).
@ -27,10 +27,10 @@
%%---------------------------------------------------------------------------- %%----------------------------------------------------------------------------
-spec start_link(any(), rabbit_net:socket(), module(), any()) -> -spec start_link(any(), module(), any()) ->
{'ok', pid(), pid()}. {'ok', pid(), pid()}.
start_link(Ref, _Sock, _Transport, _Opts) -> start_link(Ref, _Transport, _Opts) ->
{ok, SupPid} = supervisor2:start_link(?MODULE, []), {ok, SupPid} = supervisor2:start_link(?MODULE, []),
%% We need to get channels in the hierarchy here so they get shut %% We need to get channels in the hierarchy here so they get shut
%% down after the reader, so the reader gets a chance to terminate %% down after the reader, so the reader gets a chance to terminate

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -12,13 +12,13 @@
-include_lib("rabbit_common/include/rabbit.hrl"). -include_lib("rabbit_common/include/rabbit.hrl").
-export([start_link/4, start_keepalive_link/0]). -export([start_link/3, start_keepalive_link/0]).
-export([init/1]). -export([init/1]).
%%---------------------------------------------------------------------------- %%----------------------------------------------------------------------------
start_link(Ref, _Sock, _Transport, []) -> start_link(Ref, _Transport, []) ->
{ok, SupPid} = supervisor2:start_link(?MODULE, []), {ok, SupPid} = supervisor2:start_link(?MODULE, []),
{ok, KeepaliveSup} = supervisor2:start_child( {ok, KeepaliveSup} = supervisor2:start_child(
SupPid, SupPid,

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -20,9 +20,9 @@
-include_lib("rabbit_common/include/rabbit.hrl"). -include_lib("rabbit_common/include/rabbit.hrl").
-export([start_link/4, init/1]). -export([start_link/3, init/1]).
start_link(Ref, _Sock, _Transport, Configuration) -> start_link(Ref, _Transport, Configuration) ->
{ok, SupPid} = supervisor2:start_link(?MODULE, []), {ok, SupPid} = supervisor2:start_link(?MODULE, []),
{ok, HelperPid} = {ok, HelperPid} =
supervisor2:start_child(SupPid, supervisor2:start_child(SupPid,

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -21,11 +21,11 @@
-include_lib("rabbit_common/include/rabbit.hrl"). -include_lib("rabbit_common/include/rabbit.hrl").
-export([start_link/4, -export([start_link/3,
start_keepalive_link/0]). start_keepalive_link/0]).
-export([init/1]). -export([init/1]).
start_link(Ref, _Sock, Transport, Opts) -> start_link(Ref, Transport, Opts) ->
{ok, SupPid} = supervisor2:start_link(?MODULE, []), {ok, SupPid} = supervisor2:start_link(?MODULE, []),
{ok, KeepaliveSup} = {ok, KeepaliveSup} =
supervisor2:start_child(SupPid, supervisor2:start_child(SupPid,

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -39,7 +39,7 @@ ensure_listener(Listener) ->
[rabbit_cowboy_middleware, cowboy_router, cowboy_handler], [rabbit_cowboy_middleware, cowboy_router, cowboy_handler],
stream_handlers => StreamHandlers}, stream_handlers => StreamHandlers},
ProtoOptsMap), ProtoOptsMap),
Child = ranch:child_spec(rabbit_networking:ranch_ref(Listener), 100, Child = ranch:child_spec(rabbit_networking:ranch_ref(Listener),
Transport, TransportOpts, Transport, TransportOpts,
cowboy_clear, CowboyOptsMap), cowboy_clear, CowboyOptsMap),
case supervisor:start_child(?SUP, Child) of case supervisor:start_child(?SUP, Child) of

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -86,7 +86,8 @@ mqtt_init() ->
]}]), ]}]),
CowboyOpts = CowboyOpts0#{env => #{dispatch => Routes}, CowboyOpts = CowboyOpts0#{env => #{dispatch => Routes},
middlewares => [cowboy_router, rabbit_web_mqtt_middleware, cowboy_handler], middlewares => [cowboy_router, rabbit_web_mqtt_middleware, cowboy_handler],
proxy_header => get_env(proxy_protocol, false)}, proxy_header => get_env(proxy_protocol, false),
stream_handlers => [rabbit_web_mqtt_stream_handler, cowboy_stream_h]},
case get_env(tcp_config, []) of case get_env(tcp_config, []) of
[] -> ok; [] -> ok;
TCPConf0 -> start_tcp_listener(TCPConf0, CowboyOpts) TCPConf0 -> start_tcp_listener(TCPConf0, CowboyOpts)

View File

@ -12,13 +12,13 @@
-include_lib("rabbit_common/include/rabbit.hrl"). -include_lib("rabbit_common/include/rabbit.hrl").
-export([start_link/4, start_keepalive_link/0]). -export([start_link/3, start_keepalive_link/0]).
-export([init/1]). -export([init/1]).
%%---------------------------------------------------------------------------- %%----------------------------------------------------------------------------
start_link(Ref, Sock, Transport, CowboyOpts0) -> start_link(Ref, Transport, CowboyOpts0) ->
{ok, SupPid} = supervisor2:start_link(?MODULE, []), {ok, SupPid} = supervisor2:start_link(?MODULE, []),
{ok, KeepaliveSup} = supervisor2:start_child( {ok, KeepaliveSup} = supervisor2:start_child(
SupPid, SupPid,
@ -31,8 +31,7 @@ start_link(Ref, Sock, Transport, CowboyOpts0) ->
%% then have the middleware rabbit_web_mqtt_middleware place it %% then have the middleware rabbit_web_mqtt_middleware place it
%% in the initial handler state. %% in the initial handler state.
Env = maps:get(env, CowboyOpts0), Env = maps:get(env, CowboyOpts0),
CowboyOpts = CowboyOpts0#{env => Env#{keepalive_sup => KeepaliveSup, CowboyOpts = CowboyOpts0#{env => Env#{keepalive_sup => KeepaliveSup}},
socket => Sock}},
Protocol = case Transport of Protocol = case Transport of
ranch_tcp -> cowboy_clear; ranch_tcp -> cowboy_clear;
ranch_ssl -> cowboy_tls ranch_ssl -> cowboy_tls
@ -40,7 +39,7 @@ start_link(Ref, Sock, Transport, CowboyOpts0) ->
{ok, ReaderPid} = supervisor2:start_child( {ok, ReaderPid} = supervisor2:start_child(
SupPid, SupPid,
{Protocol, {Protocol,
{Protocol, start_link, [Ref, Sock, Transport, CowboyOpts]}, {Protocol, start_link, [Ref, Transport, CowboyOpts]},
intrinsic, ?WORKER_WAIT, worker, [Protocol]}), intrinsic, ?WORKER_WAIT, worker, [Protocol]}),
{ok, SupPid, ReaderPid}. {ok, SupPid, ReaderPid}.

View File

@ -7,6 +7,7 @@
-module(rabbit_web_mqtt_handler). -module(rabbit_web_mqtt_handler).
-behaviour(cowboy_websocket). -behaviour(cowboy_websocket).
-behaviour(cowboy_sub_protocol).
-export([ -export([
init/2, init/2,
@ -17,6 +18,11 @@
]). ]).
-export([close_connection/2]). -export([close_connection/2]).
%% cowboy_sub_protocol
-export([upgrade/4,
upgrade/5,
takeover/7]).
-include_lib("amqp_client/include/amqp_client.hrl"). -include_lib("amqp_client/include/amqp_client.hrl").
-record(state, { -record(state, {
@ -33,40 +39,52 @@
connection connection
}). }).
%% cowboy_sub_protcol
upgrade(Req, Env, Handler, HandlerState) ->
upgrade(Req, Env, Handler, HandlerState, #{}).
upgrade(Req, Env, Handler, HandlerState, Opts) ->
cowboy_websocket:upgrade(Req, Env, Handler, HandlerState, Opts).
takeover(Parent, Ref, Socket, Transport, Opts, Buffer, {Handler, HandlerState}) ->
Sock = case HandlerState#state.socket of
undefined ->
Socket;
ProxyInfo ->
{rabbit_proxy_socket, Socket, ProxyInfo}
end,
cowboy_websocket:takeover(Parent, Ref, Socket, Transport, Opts, Buffer,
{Handler, HandlerState#state{socket = Sock}}).
%% cowboy_websocket
init(Req, Opts) -> init(Req, Opts) ->
{PeerAddr, _PeerPort} = maps:get(peer, Req), {PeerAddr, _PeerPort} = maps:get(peer, Req),
{_, KeepaliveSup} = lists:keyfind(keepalive_sup, 1, Opts), {_, KeepaliveSup} = lists:keyfind(keepalive_sup, 1, Opts),
{_, Sock0} = lists:keyfind(socket, 1, Opts), SockInfo = maps:get(proxy_header, Req, undefined),
Sock = case maps:get(proxy_header, Req, undefined) of WsOpts0 = proplists:get_value(ws_opts, Opts, #{}),
undefined -> WsOpts = maps:merge(#{compress => true}, WsOpts0),
Sock0;
ProxyInfo ->
{rabbit_proxy_socket, Sock0, ProxyInfo}
end,
case rabbit_net:connection_string(Sock, inbound) of
{ok, ConnStr} ->
Req2 = case cowboy_req:header(<<"sec-websocket-protocol">>, Req) of Req2 = case cowboy_req:header(<<"sec-websocket-protocol">>, Req) of
undefined -> Req; undefined -> Req;
SecWsProtocol -> SecWsProtocol ->
cowboy_req:set_resp_header(<<"sec-websocket-protocol">>, SecWsProtocol, Req) cowboy_req:set_resp_header(<<"sec-websocket-protocol">>, SecWsProtocol, Req)
end, end,
WsOpts0 = proplists:get_value(ws_opts, Opts, #{}), {?MODULE, Req2, #state{
WsOpts = maps:merge(#{compress => true}, WsOpts0),
{cowboy_websocket, Req2, #state{
conn_name = ConnStr,
keepalive = {none, none}, keepalive = {none, none},
keepalive_sup = KeepaliveSup, keepalive_sup = KeepaliveSup,
parse_state = rabbit_mqtt_frame:initial_state(), parse_state = rabbit_mqtt_frame:initial_state(),
state = running, state = running,
conserve_resources = false, conserve_resources = false,
socket = Sock, socket = SockInfo,
peername = PeerAddr peername = PeerAddr
}, WsOpts}; }, WsOpts}.
_ ->
{stop, Req}
end.
websocket_init(State = #state{conn_name = ConnStr, socket = Sock, peername = PeerAddr}) -> websocket_init(State0 = #state{socket = Sock, peername = PeerAddr}) ->
case rabbit_net:connection_string(Sock, inbound) of
{ok, ConnStr} ->
State = State0#state{
conn_name = ConnStr,
socket = Sock
},
rabbit_log_connection:info("accepting Web MQTT connection ~p (~s)~n", [self(), ConnStr]), rabbit_log_connection:info("accepting Web MQTT connection ~p (~s)~n", [self(), ConnStr]),
AdapterInfo = amqp_connection:socket_adapter_info(Sock, {'Web MQTT', "N/A"}), AdapterInfo = amqp_connection:socket_adapter_info(Sock, {'Web MQTT', "N/A"}),
RealSocket = rabbit_net:unwrap_socket(Sock), RealSocket = rabbit_net:unwrap_socket(Sock),
@ -80,7 +98,10 @@ websocket_init(State = #state{conn_name = ConnStr, socket = Sock, peername = Pee
rabbit_event:init_stats_timer( rabbit_event:init_stats_timer(
State#state{proc_state = ProcessorState}, State#state{proc_state = ProcessorState},
#state.stats_timer), #state.stats_timer),
hibernate}. hibernate};
_ ->
{stop, State0}
end.
-spec close_connection(pid(), string()) -> 'ok'. -spec close_connection(pid(), string()) -> 'ok'.
close_connection(Pid, Reason) -> close_connection(Pid, Reason) ->

View File

@ -12,11 +12,9 @@
execute(Req, Env) -> execute(Req, Env) ->
#{keepalive_sup := KeepaliveSup} = Env, #{keepalive_sup := KeepaliveSup} = Env,
Sock = maps:get(socket, Env),
case maps:get(handler_opts, Env, undefined) of case maps:get(handler_opts, Env, undefined) of
undefined -> {ok, Req, Env}; undefined -> {ok, Req, Env};
Opts when is_list(Opts) -> Opts when is_list(Opts) ->
{ok, Req, Env#{handler_opts => [{keepalive_sup, KeepaliveSup}, {ok, Req, Env#{handler_opts => [{keepalive_sup, KeepaliveSup}
{socket, Sock}
|Opts]}} |Opts]}}
end. end.

View File

@ -0,0 +1,41 @@
%% This Source Code Form is subject to the terms of the Mozilla Public
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
%%
-module(rabbit_web_mqtt_stream_handler).
-behavior(cowboy_stream).
-export([init/3]).
-export([data/4]).
-export([info/3]).
-export([terminate/3]).
-export([early_error/5]).
-record(state, {next}).
init(StreamID, Req, Opts) ->
{Commands, Next} = cowboy_stream:init(StreamID, Req, Opts),
{Commands, #state{next = Next}}.
data(StreamID, IsFin, Data, State = #state{next = Next0}) ->
{Commands, Next} = cowboy_stream:data(StreamID, IsFin, Data, Next0),
{Commands, State#state{next = Next}}.
info(StreamID, {switch_protocol, Headers, _, InitialState}, State) ->
do_info(StreamID, {switch_protocol, Headers, rabbit_web_mqtt_handler, InitialState}, State);
info(StreamID, Info, State) ->
do_info(StreamID, Info, State).
do_info(StreamID, Info, State = #state{next = Next0}) ->
{Commands, Next} = cowboy_stream:info(StreamID, Info, Next0),
{Commands, State#state{next = Next}}.
terminate(StreamID, Reason, State = #state{next = Next}) ->
cowboy_stream:terminate(StreamID, Reason, Next).
early_error(StreamID, Reason, PartialReq, Resp, Opts) ->
cowboy_stream:early_error(StreamID, Reason, PartialReq, Resp, Opts).

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -12,12 +12,12 @@
-include_lib("rabbit_common/include/rabbit.hrl"). -include_lib("rabbit_common/include/rabbit.hrl").
-export([start_link/4, start_keepalive_link/0]). -export([start_link/3, start_keepalive_link/0]).
-export([init/1]). -export([init/1]).
%%---------------------------------------------------------------------------- %%----------------------------------------------------------------------------
start_link(Ref, Sock, Transport, CowboyOpts0) -> start_link(Ref, Transport, CowboyOpts0) ->
{ok, SupPid} = supervisor2:start_link(?MODULE, []), {ok, SupPid} = supervisor2:start_link(?MODULE, []),
{ok, KeepaliveSup} = supervisor2:start_child( {ok, KeepaliveSup} = supervisor2:start_child(
SupPid, SupPid,
@ -29,8 +29,8 @@ start_link(Ref, Sock, Transport, CowboyOpts0) ->
%% then have the middleware rabbit_web_mqtt_middleware place it %% then have the middleware rabbit_web_mqtt_middleware place it
%% in the initial handler state. %% in the initial handler state.
Env = maps:get(env, CowboyOpts0), Env = maps:get(env, CowboyOpts0),
CowboyOpts = CowboyOpts0#{env => Env#{keepalive_sup => KeepaliveSup, CowboyOpts = CowboyOpts0#{env => Env#{keepalive_sup => KeepaliveSup},
socket => Sock}}, stream_handlers => [rabbit_web_stomp_stream_handler, cowboy_stream_h]},
Protocol = case Transport of Protocol = case Transport of
ranch_tcp -> cowboy_clear; ranch_tcp -> cowboy_clear;
ranch_ssl -> cowboy_tls ranch_ssl -> cowboy_tls
@ -38,7 +38,7 @@ start_link(Ref, Sock, Transport, CowboyOpts0) ->
{ok, ReaderPid} = supervisor2:start_child( {ok, ReaderPid} = supervisor2:start_child(
SupPid, SupPid,
{Protocol, {Protocol,
{Protocol, start_link, [Ref, Sock, Transport, CowboyOpts]}, {Protocol, start_link, [Ref, Transport, CowboyOpts]},
intrinsic, ?WORKER_WAIT, worker, [Protocol]}), intrinsic, ?WORKER_WAIT, worker, [Protocol]}),
{ok, SupPid, ReaderPid}. {ok, SupPid, ReaderPid}.

View File

@ -7,6 +7,7 @@
-module(rabbit_web_stomp_handler). -module(rabbit_web_stomp_handler).
-behaviour(cowboy_websocket). -behaviour(cowboy_websocket).
-behaviour(cowboy_sub_protocol).
-include_lib("rabbitmq_stomp/include/rabbit_stomp.hrl"). -include_lib("rabbitmq_stomp/include/rabbit_stomp.hrl").
-include_lib("rabbitmq_stomp/include/rabbit_stomp_frame.hrl"). -include_lib("rabbitmq_stomp/include/rabbit_stomp_frame.hrl").
@ -22,6 +23,11 @@
]). ]).
-export([close_connection/2]). -export([close_connection/2]).
%% cowboy_sub_protocol
-export([upgrade/4,
upgrade/5,
takeover/7]).
-record(state, { -record(state, {
frame_type, frame_type,
heartbeat_mode, heartbeat_mode,
@ -38,17 +44,30 @@
connection connection
}). }).
%% cowboy_sub_protcol
upgrade(Req, Env, Handler, HandlerState) ->
upgrade(Req, Env, Handler, HandlerState, #{}).
upgrade(Req, Env, Handler, HandlerState, Opts) ->
cowboy_websocket:upgrade(Req, Env, Handler, HandlerState, Opts).
takeover(Parent, Ref, Socket, Transport, Opts, Buffer, {Handler, HandlerState}) ->
Sock = case HandlerState#state.socket of
undefined ->
Socket;
ProxyInfo ->
{rabbit_proxy_socket, Socket, ProxyInfo}
end,
Env0 = maps:get(env, Opts, #{}),
Env = Env0#{socket => Sock},
cowboy_websocket:takeover(Parent, Ref, Socket, Transport, maps:put(env, Env, Opts), Buffer,
{Handler, HandlerState#state{socket = Sock}}).
%% Websocket. %% Websocket.
init(Req0, Opts) -> init(Req0, Opts) ->
{PeerAddr, _PeerPort} = maps:get(peer, Req0), {PeerAddr, _PeerPort} = maps:get(peer, Req0),
{_, KeepaliveSup} = lists:keyfind(keepalive_sup, 1, Opts), {_, KeepaliveSup} = lists:keyfind(keepalive_sup, 1, Opts),
{_, Sock0} = lists:keyfind(socket, 1, Opts), SockInfo = maps:get(proxy_header, Req0, undefined),
Sock = case maps:get(proxy_header, Req0, undefined) of
undefined ->
Sock0;
ProxyInfo ->
{rabbit_proxy_socket, Sock0, ProxyInfo}
end,
Req = case cowboy_req:parse_header(<<"sec-websocket-protocol">>, Req0) of Req = case cowboy_req:parse_header(<<"sec-websocket-protocol">>, Req0) of
undefined -> Req0; undefined -> Req0;
Protocols -> Protocols ->
@ -61,14 +80,14 @@ init(Req0, Opts) ->
end, end,
WsOpts0 = proplists:get_value(ws_opts, Opts, #{}), WsOpts0 = proplists:get_value(ws_opts, Opts, #{}),
WsOpts = maps:merge(#{compress => true}, WsOpts0), WsOpts = maps:merge(#{compress => true}, WsOpts0),
{cowboy_websocket, Req, #state{ {?MODULE, Req, #state{
frame_type = proplists:get_value(type, Opts, text), frame_type = proplists:get_value(type, Opts, text),
heartbeat_sup = KeepaliveSup, heartbeat_sup = KeepaliveSup,
heartbeat = {none, none}, heartbeat = {none, none},
heartbeat_mode = heartbeat, heartbeat_mode = heartbeat,
state = running, state = running,
conserve_resources = false, conserve_resources = false,
socket = Sock, socket = SockInfo,
peername = PeerAddr, peername = PeerAddr,
auth_hd = cowboy_req:header(<<"authorization">>, Req) auth_hd = cowboy_req:header(<<"authorization">>, Req)
}, WsOpts}. }, WsOpts}.

View File

@ -32,7 +32,8 @@
init() -> init() ->
WsFrame = get_env(ws_frame, text), WsFrame = get_env(ws_frame, text),
CowboyOpts0 = maps:from_list(get_env(cowboy_opts, [])), CowboyOpts0 = maps:from_list(get_env(cowboy_opts, [])),
CowboyOpts = CowboyOpts0#{proxy_header => get_env(proxy_protocol, false)}, CowboyOpts = CowboyOpts0#{proxy_header => get_env(proxy_protocol, false),
stream_handlers => [rabbit_web_stomp_stream_handler, cowboy_stream_h]},
CowboyWsOpts = maps:from_list(get_env(cowboy_ws_opts, [])), CowboyWsOpts = maps:from_list(get_env(cowboy_ws_opts, [])),
VhostRoutes = [ VhostRoutes = [

View File

@ -12,11 +12,9 @@
execute(Req, Env) -> execute(Req, Env) ->
#{keepalive_sup := KeepaliveSup} = Env, #{keepalive_sup := KeepaliveSup} = Env,
Sock = maps:get(socket, Env),
case maps:get(handler_opts, Env, undefined) of case maps:get(handler_opts, Env, undefined) of
undefined -> {ok, Req, Env}; undefined -> {ok, Req, Env};
Opts when is_list(Opts) -> Opts when is_list(Opts) ->
{ok, Req, Env#{handler_opts => [{keepalive_sup, KeepaliveSup}, {ok, Req, Env#{handler_opts => [{keepalive_sup, KeepaliveSup}
{socket, Sock}
|Opts]}} |Opts]}}
end. end.

View File

@ -0,0 +1,41 @@
%% This Source Code Form is subject to the terms of the Mozilla Public
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved.
%%
-module(rabbit_web_stomp_stream_handler).
-behavior(cowboy_stream).
-export([init/3]).
-export([data/4]).
-export([info/3]).
-export([terminate/3]).
-export([early_error/5]).
-record(state, {next}).
init(StreamID, Req, Opts) ->
{Commands, Next} = cowboy_stream:init(StreamID, Req, Opts),
{Commands, #state{next = Next}}.
data(StreamID, IsFin, Data, State = #state{next = Next0}) ->
{Commands, Next} = cowboy_stream:data(StreamID, IsFin, Data, Next0),
{Commands, State#state{next = Next}}.
info(StreamID, {switch_protocol, Headers, _, InitialState}, State) ->
do_info(StreamID, {switch_protocol, Headers, rabbit_web_stomp_handler, InitialState}, State);
info(StreamID, Info, State) ->
do_info(StreamID, Info, State).
do_info(StreamID, Info, State = #state{next = Next0}) ->
{Commands, Next} = cowboy_stream:info(StreamID, Info, Next0),
{Commands, State#state{next = Next}}.
terminate(StreamID, Reason, State = #state{next = Next}) ->
cowboy_stream:terminate(StreamID, Reason, Next).
early_error(StreamID, Reason, PartialReq, Resp, Opts) ->
cowboy_stream:early_error(StreamID, Reason, PartialReq, Resp, Opts).

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4

View File

@ -120,7 +120,7 @@ dep_jsx = hex 2.11.0
dep_lager = hex 3.9.1 dep_lager = hex 3.9.1
dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master dep_prometheus = git https://github.com/deadtrickster/prometheus.erl.git master
dep_ra = git https://github.com/rabbitmq/ra.git master dep_ra = git https://github.com/rabbitmq/ra.git master
dep_ranch = hex 1.7.1 dep_ranch = hex 2.0.0
dep_recon = hex 2.5.1 dep_recon = hex 2.5.1
dep_observer_cli = hex 1.6.1 dep_observer_cli = hex 1.6.1
dep_stdout_formatter = hex 0.2.4 dep_stdout_formatter = hex 0.2.4