From b400e34386ec0dc3f290da6c4671d7d0621d2fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 4 Jul 2018 10:57:05 +0200 Subject: Better distinguish between Ranch and socket options A map should now be used when specifying transport options that contain more than just socket options. It is still possible to pass a list of socket options directly as a convenience. The ack_timeout is renamed to handshake_timeout when specified as a map. This corresponds to the new function ranch:handshake/1,2 that will be favored in Ranch 2.0. Specifying Ranch-specific options via the proplist will no longer be possible starting from Ranch 2.0. --- src/ranch_listener_sup.erl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ranch_listener_sup.erl') diff --git a/src/ranch_listener_sup.erl b/src/ranch_listener_sup.erl index bd4ccc5..3853425 100644 --- a/src/ranch_listener_sup.erl +++ b/src/ranch_listener_sup.erl @@ -15,27 +15,27 @@ -module(ranch_listener_sup). -behaviour(supervisor). --export([start_link/6]). +-export([start_link/5]). -export([init/1]). --spec start_link(ranch:ref(), non_neg_integer(), module(), any(), module(), any()) +-spec start_link(ranch:ref(), module(), any(), module(), any()) -> {ok, pid()}. -start_link(Ref, NumAcceptors, Transport, TransOpts, Protocol, ProtoOpts) -> - MaxConns = proplists:get_value(max_connections, TransOpts, 1024), +start_link(Ref, Transport, TransOpts, Protocol, ProtoOpts) -> + MaxConns = maps:get(max_connections, TransOpts, 1024), ranch_server:set_new_listener_opts(Ref, MaxConns, TransOpts, ProtoOpts, - [Ref, NumAcceptors, Transport, TransOpts, Protocol, ProtoOpts]), + [Ref, Transport, TransOpts, Protocol, ProtoOpts]), supervisor:start_link(?MODULE, { - Ref, NumAcceptors, Transport, Protocol + Ref, Transport, Protocol }). -init({Ref, NumAcceptors, Transport, Protocol}) -> +init({Ref, Transport, Protocol}) -> ok = ranch_server:set_listener_sup(Ref, self()), ChildSpecs = [ {ranch_conns_sup, {ranch_conns_sup, start_link, [Ref, Transport, Protocol]}, permanent, infinity, supervisor, [ranch_conns_sup]}, {ranch_acceptors_sup, {ranch_acceptors_sup, start_link, - [Ref, NumAcceptors, Transport]}, + [Ref, Transport]}, permanent, infinity, supervisor, [ranch_acceptors_sup]} ], {ok, {{rest_for_one, 1, 5}, ChildSpecs}}. -- cgit v1.2.3