Skip to content

Latest commit

 

History

History
289 lines (145 loc) · 6.32 KB

apns_erl_session_sup.md

File metadata and controls

289 lines (145 loc) · 6.32 KB

Module apns_erl_session_sup

APNS session supervisor.

Copyright (c) 2015 Silent Circle

Behaviours: supervisor.

Authors: Edwin Fine (efine@silentcircle.com).

Data Types


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

Function Index

get_child_pid/1Get a child's pid.
init/1
is_child_alive/1Test if child is alive.
start_child/2Start a child session.
start_link/1Start APNS sessions.
stop_child/1Stop child session.

Function Details

get_child_pid/1


get_child_pid(Name) -> pid() | undefined
  • Name = atom()

Get a child's pid.

init/1


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/1


is_child_alive(Name) -> boolean()
  • Name = atom()

Test if child is alive.

start_child/2


start_child(Name, Opts) -> Result

Start a child session.

  • Name - Session name (atom)

  • Opts - Options, see apns_erl_session for more details

start_link/1


start_link(Sessions) -> startlink_ret()

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/1


stop_child(Name) -> Result
  • Name = atom()
  • Result = ok | {error, Error}
  • Error = not_found | simple_one_for_one

Stop child session.