Browse Source

Change supervisor child specs to maps

juhlig 6 years ago
parent
commit
c7dcc9cb13
4 changed files with 24 additions and 21 deletions
  1. 5 5
      src/ranch_acceptors_sup.erl
  2. 6 6
      src/ranch_conns_sup_sup.erl
  3. 11 7
      src/ranch_listener_sup.erl
  4. 2 3
      src/ranch_sup.erl

+ 5 - 5
src/ranch_acceptors_sup.erl

@@ -38,13 +38,13 @@ init([Ref, NumAcceptors, Transport]) ->
 	Procs = [begin
 		LSocketId = (AcceptorId rem NumListenSockets) + 1,
 		{_, LSocket} = lists:keyfind(LSocketId, 1, LSockets),
-		{
-			{acceptor, self(), AcceptorId},
-			{ranch_acceptor, start_link, [Ref, AcceptorId, LSocket, Transport, Logger]},
-			permanent, brutal_kill, worker, []
+		#{
+			id => {acceptor, self(), AcceptorId},
+			start => {ranch_acceptor, start_link, [Ref, AcceptorId, LSocket, Transport, Logger]},
+			shutdown => brutal_kill
 		}
 	end || AcceptorId <- lists:seq(1, NumAcceptors)],
-	{ok, {{one_for_one, 1, 5}, Procs}}.
+	{ok, {#{}, Procs}}.
 
 -spec start_listen_sockets(any(), pos_integer(), module(), list(), module())
 	-> [{pos_integer(), inet:socket()}].

+ 6 - 6
src/ranch_conns_sup_sup.erl

@@ -27,9 +27,9 @@ start_link(Ref, NumConnsSups, Transport, Protocol) ->
 	}).
 
 init({Ref, NumConnsSups, Transport, Protocol}) ->
-	ChildSpecs = [
-		{{ranch_conns_sup, N}, {ranch_conns_sup, start_link,
-				[Ref, N, Transport, Protocol]},
-			permanent, infinity, supervisor, [ranch_conns_sup]}
-		|| N <- lists:seq(1, NumConnsSups)],
-	{ok, {{one_for_one, 1, 5}, ChildSpecs}}.
+	ChildSpecs = [#{
+		id => {ranch_conns_sup, N},
+		start => {ranch_conns_sup, start_link, [Ref, N, Transport, Protocol]},
+		type => supervisor
+	} || N <- lists:seq(1, NumConnsSups)],
+	{ok, {#{}, ChildSpecs}}.

+ 11 - 7
src/ranch_listener_sup.erl

@@ -33,11 +33,15 @@ start_link(Ref, Transport, TransOpts, Protocol, ProtoOpts) ->
 init({Ref, NumAcceptors, NumConnsSups, Transport, Protocol}) ->
 	ok = ranch_server:set_listener_sup(Ref, self()),
 	ChildSpecs = [
-		{ranch_conns_sup_sup, {ranch_conns_sup_sup, start_link,
-				[Ref, NumConnsSups, Transport, Protocol]},
-			permanent, infinity, supervisor, [ranch_conns_sup_sup]},
-		{ranch_acceptors_sup, {ranch_acceptors_sup, start_link,
-				[Ref, NumAcceptors, Transport]},
-			permanent, infinity, supervisor, [ranch_acceptors_sup]}
+		#{
+			id => ranch_conns_sup_sup,
+			start => {ranch_conns_sup_sup, start_link, [Ref, NumConnsSups, Transport, Protocol]},
+			type => supervisor
+		},
+		#{
+			id => ranch_acceptors_sup,
+			start => {ranch_acceptors_sup, start_link, [Ref, NumAcceptors, Transport]},
+			type => supervisor
+		}
 	],
-	{ok, {{rest_for_one, 1, 5}, ChildSpecs}}.
+	{ok, {#{strategy => rest_for_one}, ChildSpecs}}.

+ 2 - 3
src/ranch_sup.erl

@@ -34,7 +34,6 @@ init([]) ->
 	ranch_server = ets:new(ranch_server, [
 		ordered_set, public, named_table]),
 	Procs = [
-		{ranch_server, {ranch_server, start_link, []},
-			permanent, 5000, worker, [ranch_server]}
+		#{id => ranch_server, start => {ranch_server, start_link, []}}
 	],
-	{ok, {{one_for_one, Intensity, Period}, Procs}}.
+	{ok, {#{intensity => Intensity, period => Period}, Procs}}.