From 2730f7188738cc7b1100e50bcc8567d33ecb3934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 31 May 2017 14:11:38 +0200 Subject: 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. --- src/ranch.erl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/ranch.erl') 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) -- cgit v1.2.3