View Source brod_supervisor3 behaviour (brod v4.0.0)

Summary

Types

-type call() :: which_children | count_children | {_, _}.
XXX: refine
-type child() :: undefined | pid().
-type child_id() :: term().
-type child_rec() ::
          #child{pid :: child() | {restarting, pid()} | {delayed_restart, tref()} | [pid()],
                 name :: child_id(),
                 mfargs :: mfargs(),
                 restart_type :: restart(),
                 shutdown :: shutdown(),
                 child_type :: worker(),
                 modules :: modules()}.
-type child_spec() ::
          {Id :: child_id(),
           StartFunc :: mfargs(),
           Restart :: restart(),
           Shutdown :: shutdown(),
           Type :: worker(),
           Modules :: modules()}.
-type delay() :: non_neg_integer().
-type dynamics() :: dict:dict() | sets:set().
-type init_sup_name() :: sup_name() | self.
-type mfargs() :: {M :: module(), F :: atom(), A :: [term()] | undefined}.
-type modules() :: [module()] | dynamic.
-type restart() ::
          permanent | transient | temporary | intrinsic |
          {permanent, delay()} |
          {transient, delay()} |
          {intrinsic, delay()}.
-type shutdown() :: brutal_kill | timeout().
-type startchild_err() :: already_present | {already_started, Child :: child()} | term().
-type startchild_ret() ::
          {ok, Child :: child()} | {ok, Child :: child(), Info :: term()} | {error, startchild_err()}.
-type state() ::
          #state{name :: atom(),
                 strategy :: strategy(),
                 children :: [child_rec()],
                 dynamics :: dynamics(),
                 intensity :: non_neg_integer(),
                 period :: pos_integer(),
                 restarts :: list(),
                 module :: module(),
                 args :: list()}.
-type stop_rsn() ::
          {shutdown, term()} |
          {bad_return, {module(), init, term()}} |
          {bad_start_spec, term()} |
          {start_spec, term()} |
          {supervisor_data, term()}.
-type strategy() :: one_for_all | one_for_one | rest_for_one | simple_one_for_one.
-type sup_name() :: {local, Name :: atom()} | {global, Name :: atom()}.
-type sup_ref() ::
          (Name :: atom()) | {Name :: atom(), Node :: node()} | {global, Name :: atom()} | pid().
-type tref() :: reference().
-type worker() :: worker | supervisor.

Callbacks

-callback init(Args :: term()) ->
                  {ok,
                   {{RestartStrategy :: strategy(), MaxR :: non_neg_integer(), MaxT :: non_neg_integer()},
                    [ChildSpec :: child_spec()]}} |
                  ignore | post_init.
-callback post_init(Args :: term()) ->
                       {ok,
                        {{RestartStrategy :: strategy(),
                          MaxR :: non_neg_integer(),
                          MaxT :: non_neg_integer()},
                         [ChildSpec :: child_spec()]}} |
                       ignore.

Functions

Link to this function

check_childspecs(ChildSpecs)

View Source
-spec check_childspecs(ChildSpecs) -> Result
                          when ChildSpecs :: [child_spec()], Result :: ok | {error, Error :: term()}.
Link to this function

code_change(_, State, _)

View Source
-spec code_change(term(), state(), term()) -> {ok, state()} | {error, term()}.
-spec count_children(SupRef) -> PropListOfCounts
                        when
                            SupRef :: sup_ref(),
                            PropListOfCounts :: [Count],
                            Count ::
                                {specs, ChildSpecCount :: non_neg_integer()} |
                                {active, ActiveProcessCount :: non_neg_integer()} |
                                {supervisors, ChildSupervisorCount :: non_neg_integer()} |
                                {workers, ChildWorkerCount :: non_neg_integer()}.
Link to this function

delete_child(SupRef, Id)

View Source
-spec delete_child(SupRef, Id) -> Result
                      when
                          SupRef :: sup_ref(),
                          Id :: child_id(),
                          Result :: ok | {error, Error},
                          Error :: running | restarting | not_found | simple_one_for_one.
Link to this function

find_child(Supervisor, Name)

View Source
-spec find_child(Supervisor, Name) -> [pid()] when Supervisor :: sup_ref(), Name :: child_id().
Link to this function

handle_call(_, From, State)

View Source
-spec handle_call(call(), term(), state()) -> {reply, term(), state()}.
-spec handle_cast({try_again_restart, child_id() | pid(), term()}, state()) ->
                     {noreply, state()} | {stop, shutdown, state()}.
-spec handle_info(term(), state()) -> {noreply, state()} | {stop, term(), state()}.
-spec init({init_sup_name(), module(), [term()]}) -> {ok, state()} | ignore | {stop, stop_rsn()}.
Link to this function

restart_child(SupRef, Id)

View Source
-spec restart_child(SupRef, Id) -> Result
                       when
                           SupRef :: sup_ref(),
                           Id :: child_id(),
                           Result ::
                               {ok, Child :: child()} |
                               {ok, Child :: child(), Info :: term()} |
                               {error, Error},
                           Error :: running | restarting | not_found | simple_one_for_one | term().
Link to this function

start_child(SupRef, ChildSpec)

View Source
-spec start_child(SupRef, ChildSpec) -> startchild_ret()
                     when SupRef :: sup_ref(), ChildSpec :: child_spec() | (List :: [term()]).
Link to this function

start_link(Module, Args)

View Source
-spec start_link(Module, Args) -> startlink_ret() when Module :: module(), Args :: term().
Link to this function

start_link(SupName, Module, Args)

View Source
-spec start_link(SupName, Module, Args) -> startlink_ret()
                    when SupName :: sup_name(), Module :: module(), Args :: term().
Link to this function

terminate(Reason, State)

View Source
-spec terminate(term(), state()) -> ok.
Link to this function

terminate_child(SupRef, Id)

View Source
-spec terminate_child(SupRef, Id) -> Result
                         when
                             SupRef :: sup_ref(),
                             Id :: pid() | child_id(),
                             Result :: ok | {error, Error},
                             Error :: not_found | simple_one_for_one.
Link to this function

try_again_restart(SupRef, Child, Reason)

View Source
-spec try_again_restart(SupRef, Child, Reason) -> ok
                           when SupRef :: sup_ref(), Child :: child_id() | pid(), Reason :: term().
-spec which_children(SupRef) -> [{Id, Child, Type, Modules}]
                        when
                            SupRef :: sup_ref(),
                            Id :: child_id() | undefined,
                            Child :: child() | restarting,
                            Type :: worker(),
                            Modules :: modules().