Deleted some un-implemented things from irc_net_sup, and changed some formatting...
authorMatt Mullins <mmullins@mmlx.us>
Wed, 18 May 2011 05:17:24 +0000 (00:17 -0500)
committerMatt Mullins <mmullins@mmlx.us>
Wed, 18 May 2011 05:17:24 +0000 (00:17 -0500)
irc/irc_net_sup.erl

index 87dc4c0..64d0e6b 100644 (file)
@@ -8,8 +8,6 @@
 
 -export([
           start_link/4,
-                 get_channel_sup/1,
-                 get_user_sup/1
                ]).
 -export([init/1]).
 
@@ -17,39 +15,15 @@ start_link(Instance, Host, Port, Nick) ->
        supervisor:start_link(?MODULE,
                {Instance, Host, Port, Nick}).
 
-get_channel_sup(Pid) ->
-       get_sup(Pid, channels).
-
-get_user_sup(Pid) ->
-       get_sup(Pid, users).
-
-% TODO: should this crash and burn if the child isn't running?
-%       i.e. can this become a race condition with the actual
-%       respawning of a process?
-get_sup(Pid, Type) ->
-       case supervisor:start_child(Pid,
-                       data_child(Type, ok, []))
-       of
-               {error, {already_started, Child}} ->
-                       Child
-       end.
-
 init({Instance, Host, Port, Nick}) ->
        Connection = {connection,
-                 {irc_conn, start_link, [self(), Instance, Host, Port, Nick]},
-                 transient, 5, worker, [irc_conn]},
-       Children = [data_child(channels, irc_channel_sup, [Instance]),
-                   data_child(users, irc_user_sup, [Instance]),
-                               Connection
-                          ],
-       RestartStrategy = {one_for_all, 0, 1}, % TODO
+                  {irc_conn, start_link, [Instance, Host, Port, Nick]},
+                  permanent, % persistence type ("Restart" in the manual)
+                  5,         % shutdown [sends signal, with timeout for response]
+                  worker,    % it's not a supervisor itself
+                  [irc_conn] % modules it uses
+                 },
+       Children = [Connection],
+       RestartStrategy = {one_for_all, 5, 60}, % Die if a child dies more than 5
+                                            % times in 60 seconds.
        {ok, {RestartStrategy, Children}}.
-
-data_child(Id, Module, Args) ->
-       {Id,
-        {Module, start_link, Args},
-        permanent,
-        5,
-        supervisor,
-        [Module]}.
-