Browse Source

No longer accept mix of Ranch/socket options as list

Loïc Hoguin 6 years ago
parent
commit
6012eee1ba

+ 1 - 24
doc/src/manual/ranch.asciidoc

@@ -64,23 +64,6 @@ when accepting new connections. Some connections may
 also be removed from this count explicitly by the user
 code.
 
-=== opt()
-
-[source,erlang]
-----
-opt() = {ack_timeout, timeout()}
-      | {connection_type, worker | supervisor}
-      | {max_connections, max_conns()}
-      | {num_acceptors, pos_integer()}
-      | {shutdown, timeout() | brutal_kill}
-----
-
-Deprecated form for Ranch-specific options.
-
-Please use the `opts()` type when you need to provide
-Ranch-specific transport options. Socket options will
-remain separate from the Ranch-specific options.
-
 === opts()
 
 [source,erlang]
@@ -106,13 +89,6 @@ option needs to be given) or as part of `socket_opts`.
 
 None of the options are required.
 
-ack_timeout::
-
-When `ack_timeout` is found in a transport options proplist,
-it is converted to the `handshake_timeout` option from the
-map. They are equivalent. The `ack_timeout` option will be
-removed in Ranch 2.0.
-
 connection_type (worker)::
 
 Type of process that will handle the connection.
@@ -158,6 +134,7 @@ Unique name used to refer to a listener.
 * *2.0*: The option `max_connections` is now per connection supervisor.
 * *2.0*: The `num_conns_sup` option was added.
 * *2.0*: The `socket` option was removed.
+* *2.0*: The `opt()` type was removed.
 * *1.6*: The `logger` option was added.
 * *1.6*: The `opt()` type was deprecated in favor of the new `opts()` type.
 

+ 2 - 0
doc/src/manual/ranch.child_spec.asciidoc

@@ -74,6 +74,8 @@ Child specifications are returned.
 
 == Changelog
 
+* *2.0*: The `TransOpts` argument must no longer contain
+         Ranch-specific options if given as a list. Use a map.
 * *1.4*: The `NumAcceptors` argument was moved to the transport options.
 
 == Examples

+ 5 - 0
doc/src/manual/ranch.set_transport_options.asciidoc

@@ -34,6 +34,11 @@ The new transport options.
 
 The atom `ok` is always returned. It can be safely ignored.
 
+== Changelog
+
+* *2.0*: The `TransOpts` argument must no longer contain
+         Ranch-specific options if given as a list. Use a map.
+
 == Examples
 
 .Set the transport options

+ 2 - 0
doc/src/manual/ranch.start_listener.asciidoc

@@ -82,6 +82,8 @@ configured for Ranch is already in use.
 
 == Changelog
 
+* *2.0*: The `TransOpts` argument must no longer contain
+         Ranch-specific options if given as a list. Use a map.
 * *1.4*: The `NumAcceptors` argument was moved to the transport options.
 
 == Examples

+ 0 - 48
src/ranch.erl

@@ -51,14 +51,6 @@
 -type max_conns() :: non_neg_integer() | infinity.
 -export_type([max_conns/0]).
 
-%% This type is deprecated and will be removed in Ranch 2.0.
--type opt() :: {ack_timeout, timeout()}
-	| {connection_type, worker | supervisor}
-	| {max_connections, max_conns()}
-	| {num_acceptors, pos_integer()}
-	| {shutdown, timeout() | brutal_kill}.
--export_type([opt/0]).
-
 -type opts() :: any() | #{
 	connection_type => worker | supervisor,
 	handshake_timeout => timeout(),
@@ -99,49 +91,9 @@ start_listener(Ref, NumAcceptors, Transport, TransOpts0, Protocol, ProtoOpts)
 -spec normalize_opts(opts()) -> opts().
 normalize_opts(Map) when is_map(Map) ->
 	Map;
-normalize_opts(List0) when is_list(List0) ->
-	Map0 = #{},
-	{Map1, List1} = case take(ack_timeout, List0) of
-		{value, HandshakeTimeout, Tail0} ->
-			{Map0#{handshake_timeout => HandshakeTimeout}, Tail0};
-		false ->
-			{Map0, List0}
-	end,
-	{Map, List} = lists:foldl(fun(Key, {Map2, List2}) ->
-		case take(Key, List2) of
-			{value, ConnectionType, Tail2} ->
-				{Map2#{Key => ConnectionType}, Tail2};
-			false ->
-				{Map2, List2}
-		end
-	end, {Map1, List1}, [connection_type, max_connections, num_acceptors, shutdown]),
-	if
-		Map =:= #{} ->
-			ok;
-		true ->
-			log(warning,
-				"Setting Ranch options together with socket options "
-				"is deprecated. Please use the new map syntax that allows "
-				"specifying socket options separately from other options.~n",
-				[], Map)
-	end,
-	case List of
-		[] -> Map;
-		_ -> Map#{socket_opts => List}
-	end;
 normalize_opts(Any) ->
 	#{socket_opts => Any}.
 
-take(Key, List) ->
-	take(Key, List, []).
-
-take(_, [], _) ->
-	false;
-take(Key, [{Key, Value}|Tail], Acc) ->
-	{value, Value, lists:reverse(Acc, Tail)};
-take(Key, [Value|Tail], Acc) ->
-	take(Key, Tail, [Value|Acc]).
-
 maybe_started({error, {{shutdown,
 		{failed_to_start_child, ranch_acceptors_sup,
 			{listen_error, _, Reason}}}, _}} = Error) ->