Version: 18.4.29
This module defines the director behaviour.
Required callback functions: init/1, handle_start/4, handle_terminate/5, handle_exit/5, terminate/2.
Authors: Pouriya Jahanbakhsh (pouriya.jahanbakhsh@gmail.com).
action() = restart | {restart, pos_integer()} | delete | wait | stop | {stop, Reason::any()}
append() = boolean()
callback_return_option() = {log, boolean()}
callback_return_options() = [callback_return_option()] | []
child_state() = any()
childspec() = #{id => id(), start => start(), terminate_timeout => terminate_timeout(), type => type(), modules => modules(), append => append(), delete => delete(), state => child_state()}
default_childspec() = #{start => start(), terminate_timeout => terminate_timeout(), type => type(), modules => modules(), delete => delete(), state => child_state()}
delete() = boolean()
director() = pid() | atom() | tuple()
handle_exit_return() = {action(), child_state(), state(), callback_return_options()}
handle_start_return() = {ok, child_state(), state(), callback_return_options()} | {stop, reason(), child_state(), callback_return_options()}
handle_terminate_return() = {ok, child_state(), state(), callback_return_options()} | {stop, reason(), child_state(), callback_return_options()}
id() = term()
init_arg() = any()
init_return() = ok | {ok, state()} | {ok, state(), [childspec()] | []} | {ok, state(), [childspec()] | [], default_childspec()} | {ok, state(), [childspec()] | [], start_options()} | {ok, state(), [childspec()] | [], default_childspec(), start_options()} | ignore | {stop, Reason::any()}
metadata_arg() = #{pid => pid(), extra => any(), restart_count => non_neg_integer()}
modules() = [module()] | dynamic
reason() = any()
register_name() = {local, atom()} | {global, atom()} | {via, module(), term()}
start() = module() | {module(), function()} | mfa()
start_option() = {debug, [sys:dbg_opt()] | []} | {spawn_opt, proc_lib:spawn_option()} | {timeout, timeout()} | {table_module, module()} | {table_init_argument, any()} | {delete_table, boolean()}
start_options() = [start_option()] | []
start_return() = {ok, pid()} | {ok, pid(), any()} | ignore | {error, term()}
state() = any()
terminate_return() = {ok, callback_return_options()} | {new_error, NewReason::any(), callback_return_options()} | any()
terminate_timeout() = timeout()
type() = worker | supervisor | sup | s | w
| become_supervisor/3 | Tells director process become supervisor of this Pid with this Childspec. |
| change_default_childspec/2 | Changes director's default childspec. |
| check_childspec/1 | checks childspec. |
| count_children/1 | Returns count of children. |
| default_childspec/0 | Returns default childspec of director application (Not a running director process). |
| delete_child/2 | Deletes a terminated or waited child using child id. |
| delete_running_child/2 | Tells to director process delete running child with process id Pid and let it free! |
| get_childspec/2 | Returns childspec of child id or child pid. |
| get_default_childspec/1 | Returns director process's default childspec. |
| get_pid/2 | Returns pid of child id if child is running. |
| get_pids/1 | Returns list of {id, pid}s for all running children. |
| get_restart_count/2 | Returns restart count of child id. |
| restart_child/2 | Restarts a terminated or waited child using child id. |
| start/2 | Starts stand-alone director. |
| start/3 | Starts stand-alone director. |
| start/4 | Starts stand-alone director. |
| start_child/2 | Starts a child using childspec. |
| start_link/2 | Starts and links a director. |
| start_link/3 | Starts and links a director. |
| start_link/4 | Starts and links a director with start options. |
| stop/1 | Stops director process with reason termination 'normal' and 'infinity' as timeout. |
| stop/2 | Stops director process with 'infinity' timeout. |
| stop/3 | Stops director process. |
| terminate_and_delete_child/2 | Terminates running child and deletes it using child id or pid of child. |
| terminate_child/2 | terminates a running child using child id or child pid. |
| which_children/1 | Returns information about each child. |
become_supervisor(Director::director(), Pid::pid(), ChildSpec::childspec()) -> ok | {error, noproc | term()}
Tells director process become supervisor of this Pid with this Childspec.
Pid should be alive Erlang process on same node.
After this, new child process will have an Erlang message {'change_parent', NewParentPid} in
Its mailbox.
Error maybe occur for reading from or inserting to table.
change_default_childspec(Director::director(), DefChildSpec::default_childspec()) -> {ok, default_childspec()} | {error, Reason::term()}
Changes director's default childspec.
Be careful about using this. This may change all children behavior with append => true in
their next restart.
check_childspec(ChildSpec::childspec()) -> ok | {error, Reason::term()}
checks childspec.
This code will execute in process of caller.
count_children(Director::director()) -> [{specs, non_neg_integer()} | {active, non_neg_integer()} | {supervisors, non_neg_integer()} | {workers, non_neg_integer()}] | {error, term()}
Returns count of children.
Error maybe occur for reading from table.
default_childspec() -> default_childspec()
Returns default childspec of director application (Not a running director process).
delete_child(Director::director(), Id::id()) -> ok | {error, Reason::not_found | running | not_parent | term()}
Deletes a terminated or waited child using child id.
Error maybe occur for reading from or inserting to table.
delete_running_child(Director::director(), Pid::pid()) -> ok | {error, not_found | term()}
Tells to director process delete running child with process id Pid and let it free!
Sometime it's useful to make a process unsupervised or you may want to change the parent.
For changing parent after calling this you should call 'become_supervisor'/3-4 with new
director as new parent.
get_childspec(Director::director(), Id_or_Pid::id() | pid()) -> {ok, childspec()} | {error, not_found | term()}
Returns childspec of child id or child pid.
Error maybe occur for reading from table.
get_default_childspec(Director::director()) -> default_childspec()
Returns director process's default childspec.
get_pid(Director::director(), Id::id()) -> {ok, pid()} | {error, not_found | restarting | undefined | term()}
Returns pid of child id if child is running.
Error maybe occur for reading from table.
get_pids(Director::director()) -> {ok, [{id(), pid()}] | []} | {error, term()}
Returns list of {id, pid}s for all running children.
Error maybe occur for reading from table.
get_restart_count(Director::director(), Id::id()) -> {ok, non_neg_integer()} | {error, not_found | term()}
Returns restart count of child id.
Error maybe occur for reading from table.
restart_child(Director::director(), Id::id()) -> {ok, pid()} | {ok, pid(), Extra::term()} | {error, Reason::running | restarting | not_found | term()}
Restarts a terminated or waited child using child id.
Reason of error may be for starting process or table.
start(Mod::module(), InitArg::init_arg()) -> start_return()
Starts stand-alone director.
start(Name::register_name() | module(), Mod::module() | init_arg(), InitArg::init_arg() | start_options()) -> start_return()
Starts stand-alone director.
start(Name::register_name(), Mod::module(), InitArg::init_arg(), Opts::start_options()) -> start_return()
Starts stand-alone director.
start_child(Director::director(), ChildSpec::childspec()) -> start_return()
Starts a child using childspec.
{'ok', 'undefined'} is for a child which ignored to start.
Reason of error may be for childspec not starting of process.
start_link(Mod::module(), InitArg::init_arg()) -> start_return()
Starts and links a director.
start_link(Name::register_name() | module(), Mod::module() | init_arg(), InitArg::init_arg() | start_options()) -> start_return()
Starts and links a director.
start_link(Name::register_name(), Mod::module(), InitArg::init_arg(), Opts::start_options()) -> start_return()
Starts and links a director with start options.
stop(Director::director()) -> ok
Stops director process with reason termination 'normal' and 'infinity' as timeout.
stop(Director::director(), Reason::reason()) -> ok
Stops director process with 'infinity' timeout.
stop(Director::director(), Reason::reason(), Timeout::timeout()) -> ok
Stops director process.
terminate_and_delete_child(Director::director(), Id::id() | pid()) -> ok | {error, not_found | not_parent | term()}
Terminates running child and deletes it using child id or pid of child.
If this supervisor is not owner of child and has access to children table, it cannot
terminate child and error {error, not_parent} will occur.
Error maybe occur for reading from or inserting to table.
terminate_child(Director::director(), Id_or_Pid::id() | pid()) -> ok | {error, Reason::not_found | not_parent | term()}
terminates a running child using child id or child pid.
If this supervisor is not owner of child and has access to children table, it cannot
terminate child and {error, not_parent} error will return.
which_children(Director::director()) -> [{id(), type(), pid() | restarting | undefined, modules()}] | [] | {error, term()}
Returns information about each child.
Error maybe occur for reading from table.
Generated by EDoc