APNS session supervisor.
Copyright (c) 2015 Silent Circle
Behaviours: supervisor
.
Authors: Edwin Fine (efine@silentcircle.com
).
child() = undefined | pid()
child_id() = term()
Not a pid().
child_spec() = {Id::child_id(), StartFunc::mfargs(), Restart::restart(), Shutdown::shutdown(), Type::worker(), Modules::modules()}
mfargs() = {M::module(), F::atom(), A::[term()] | undefined}
modules() = [module()] | dynamic
proplist() = [proplists:property()]
restart() = permanent | transient | temporary
session_props() = proplist()
shutdown() = brutal_kill | timeout()
startchild_err() = already_present | {already_started, Child::child()} | term()
startchild_ret() = {ok, Child::child()} | {ok, Child::child(), Info::term()} | {error, startchild_err()}
startlink_err() = {already_started, pid()} | {shutdown, term()} | term()
startlink_ret() = {ok, pid()} | ignore | {error, startlink_err()}
strategy() = one_for_all | one_for_one | rest_for_one | simple_one_for_one
worker() = worker | supervisor
get_child_pid/1 | Get a child's pid. |
init/1 | |
is_child_alive/1 | Test if child is alive. |
start_child/2 | Start a child session. |
start_link/1 | Start APNS sessions. |
stop_child/1 | Stop child session. |
get_child_pid(Name) -> pid() | undefined
Name = atom()
Get a child's pid.
init(Args) -> Result
Args = term()
Result = {ok, {{Strategy, MaxR, MaxT}, Children}}
Strategy = strategy()
MaxR = non_neg_integer()
MaxT = pos_integer()
Children = [child_spec()]
is_child_alive(Name) -> boolean()
Name = atom()
Test if child is alive.
start_child(Name, Opts) -> Result
Name = atom()
Opts = proplist()
Result = startchild_ret()
Start a child session.
-
Name
- Session name (atom) -
Opts
- Options, seeapns_erl_session
for more details
start_link(Sessions) -> startlink_ret()
Sessions = [session_props()]
Start APNS sessions.
Sessions
is a list of proplists and looks like this:
[
[
{name, 'apns-com.example.Example'},
{config, [
{host, "gateway.sandbox.push.apple.com"},
{port, 2195},
{bundle_seed_id, <<"com.example.Example">>},
{bundle_id, <<"com.example.Example">>},
{fake_token, <<"XXXXXX">>},
{retry_delay, 1000},
{checkpoint_period, 60000},
{checkpoint_max, 10000},
{close_timeout, 5000},
{ssl_opts, [
{certfile, "/etc/somewhere/certs/com.example.Example--DEV.cert.pem"},
{keyfile, "/etc/somewhere/certs/com.example.Example--DEV.key.unencrypted.pem"}
]
}
]}
] %, ...
]
stop_child(Name) -> Result
Name = atom()
Result = ok | {error, Error}
Error = not_found | simple_one_for_one
Stop child session.