aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-05-31 14:11:38 +0200
committerLoïc Hoguin <[email protected]>2017-05-31 14:11:38 +0200
commit2730f7188738cc7b1100e50bcc8567d33ecb3934 (patch)
tree66d1daac50363684954316dc6b371a51188ce6f8 /src
parenta004ad710eddd0c21aaccc30d5633a76b06164b5 (diff)
downloadranch-2730f7188738cc7b1100e50bcc8567d33ecb3934.tar.gz
ranch-2730f7188738cc7b1100e50bcc8567d33ecb3934.tar.bz2
ranch-2730f7188738cc7b1100e50bcc8567d33ecb3934.zip
Deprecated ranch:start_listener/6 and child_spec/6
The NumAcceptors argument has been moved to transport option num_acceptor, which defaults to 10. The functions now take one less argument. The old functions are still here, though deprecated.
Diffstat (limited to 'src')
-rw-r--r--src/ranch.erl17
-rw-r--r--src/ranch_acceptors_sup.erl3
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)