gen_tcp
acceptor pool supervisor.
Behaviours: gen_server.
This module defines the acceptor_pool behaviour.
Required callback functions: init/1.
See also: acceptor, supervisor.
gen_tcp
acceptor pool supervisor. An
acceptor_pool
must define the acceptor_pool
behaviour callback, which is
very similar to the supervisor
behaviour except all children must be
acceptor
proccesses and only the map terms are supported.
The only callback is init/1
:
-callback init(Args) -> {ok, {PoolFlags, [AcceptorSpec, ...]}} | ignore when Args :: any(), PoolFlags :: pool_flags(), AcceptorSpec :: acceptor_spec().
The pool_flags()
are the intensity
and period
pairs as in as
supervisor:sup_flags/0
and have the equivalent behaviour.
acceptor_spec()
, just as there can only be a
single supervisor:child_spec/0
when the strategy
is simple_one_for_one
.
The map pairs are the same as supervisor:child_spec/0
except that start
's
value is of form:
{AcceptorMod :: module(), AcceptorArg :: term(), Opts :: [acceptor:option()]}
AcceptorMod
is an acceptor
callback module that will be called with
argument AcceptorArg
, and spawned with acceptor options Opts
.
There is an additional grace
key, that has a timeout()
value. This is
the time in milliseconds that the acceptor pool will wait for children to
exit before starting to shut them down when terminating. This allows
connections to be gracefully closed.
acceptor_pool
call
accept_socket/3
.
acceptor_spec() = #{id := term(), start := {module(), any(), [acceptor:option()]}, restart => permanent | transient | temporary, shutdown => timeout() | brutal_kill, grace => timeout(), type => worker | supervisor, modules => [module()] | dynamic}
name() = {inet:ip_address(), inet:port_number()} | inet:returned_non_ip_address()
pool() = pid() | atom() | {atom(), node()} | {via, module(), any()} | {global, any()}
pool_flags() = #{intensity => non_neg_integer(), period => pos_integer()}
accept_socket/3 | Ask acceptor_pool Pool to accept on the listen socket Sock with
Acceptors number of acceptors. |
count_children/1 | Count the children of the acceptor_pool . |
start_link/2 | Start an acceptor_pool with callback module Module and argument
Args . |
start_link/3 | Start an acceptor_pool with name Name , callback module Module and
argument Args . |
which_children/1 | List the children of the acceptor_pool . |
which_sockets/1 | List the listen sockets being used by the acceptor_pool . |
accept_socket(Pool, Sock, Acceptors) -> {ok, Ref} | {error, Reason}
Ask acceptor_pool
Pool
to accept on the listen socket Sock
with
Acceptors
number of acceptors.
{ok, Ref}
on success or {error, Reason}
on failure. If acceptors
fail to accept connections an exit signal is sent Sock
.
count_children(Pool) -> Counts
Count the children of the acceptor_pool
.
active
.
See also: supervisor:count_children/1.
start_link(Module, Args) -> {ok, Pid} | ignore | {error, Reason}
Start an acceptor_pool
with callback module Module
and argument
Args
.
See also: start_link/3.
start_link(Name, Module, Args) -> {ok, Pid} | ignore | {error, Reason}
Start an acceptor_pool
with name Name
, callback module Module
and
argument Args
.
supervisor:start_link/3
except starts an
acceptor_pool
instead of a supervisor
.
See also: supervisor:start_link/3.
which_children(Pool) -> [{Id, Child, Type, Modules}]
List the children of the acceptor_pool
.
This function is equivalent to supervisor:which_children/1
except that the
peer name, listen socket name and a unique reference are combined with the
id
from init/1
.
See also: supervisor:which_children/1.
which_sockets(Pool) -> [{SockModule, SockName, Sock, Ref}]
List the listen sockets being used by the acceptor_pool
.
Generated by EDoc, Sep 19 2016, 00:22:34.