diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ranch.erl | 17 | ||||
-rw-r--r-- | src/ranch_acceptors_sup.erl | 3 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/ranch.erl b/src/ranch.erl index 2ef6222..e835ad5 100644 --- a/src/ranch.erl +++ b/src/ranch.erl @@ -14,8 +14,10 @@ -module(ranch). +-export([start_listener/5]). -export([start_listener/6]). -export([stop_listener/1]). +-export([child_spec/5]). -export([child_spec/6]). -export([accept_ack/1]). -export([remove_connection/1]). @@ -31,12 +33,15 @@ -export([set_option_default/3]). -export([require/1]). +-deprecated([start_listener/6, child_spec/6]). + -type max_conns() :: non_neg_integer() | infinity. -export_type([max_conns/0]). -type opt() :: {ack_timeout, timeout()} | {connection_type, worker | supervisor} | {max_connections, max_conns()} + | {num_acceptors, pos_integer()} | {shutdown, timeout() | brutal_kill} | {socket, any()}. -export_type([opt/0]). @@ -44,6 +49,12 @@ -type ref() :: any(). -export_type([ref/0]). +-spec start_listener(ref(), module(), any(), module(), any()) + -> supervisor:startchild_ret(). +start_listener(Ref, Transport, TransOpts, Protocol, ProtoOpts) -> + NumAcceptors = proplists:get_value(num_acceptors, TransOpts, 10), + start_listener(Ref, NumAcceptors, Transport, TransOpts, Protocol, ProtoOpts). + -spec start_listener(ref(), non_neg_integer(), module(), any(), module(), any()) -> supervisor:startchild_ret(). start_listener(Ref, NumAcceptors, Transport, TransOpts, Protocol, ProtoOpts) @@ -99,6 +110,12 @@ stop_listener(Ref) -> {error, Reason} end. +-spec child_spec(ref(), module(), any(), module(), any()) + -> supervisor:child_spec(). +child_spec(Ref, Transport, TransOpts, Protocol, ProtoOpts) -> + NumAcceptors = proplists:get_value(num_acceptors, TransOpts, 10), + child_spec(Ref, NumAcceptors, Transport, TransOpts, Protocol, ProtoOpts). + -spec child_spec(ref(), non_neg_integer(), module(), any(), module(), any()) -> supervisor:child_spec(). child_spec(Ref, NumAcceptors, Transport, TransOpts, Protocol, ProtoOpts) diff --git a/src/ranch_acceptors_sup.erl b/src/ranch_acceptors_sup.erl index 24cce2b..7092ab8 100644 --- a/src/ranch_acceptors_sup.erl +++ b/src/ranch_acceptors_sup.erl @@ -30,8 +30,9 @@ init([Ref, NumAcceptors, Transport, TransOpts]) -> TransOpts2 = proplists:delete(ack_timeout, proplists:delete(connection_type, proplists:delete(max_connections, + proplists:delete(num_acceptors, proplists:delete(shutdown, - proplists:delete(socket, TransOpts))))), + proplists:delete(socket, TransOpts)))))), case Transport:listen(TransOpts2) of {ok, Socket} -> Socket; {error, Reason} -> listen_error(Ref, Transport, TransOpts2, Reason) |