delayed_otp v0.0.4 DelayedSup

The API is exactly the same as Elixir stdlib Supervisor, except that the supervisor options now supports :delay_fun as an option.

The signature of :delay_fun is: (child_id :: term, ms_lifetime :: integer, acc :: term) -> {ms_delay_death :: integer, newacc:: term} The second argument ms_lifetime is the lifetime of the previously dead process. First start accumulator is nil.

This delay will be the minimum lifetime of the child in millisecond : child death will be delayed if it occurs too soon.

Below an example usage with an exponential backoff strategy: (200*2^count) ms delay where the backoff count is reset when previous run lifetime was > 5 secondes.

iex> import DelayedSup.Spec
  ...> import Bitwise
  ...> DelayedSup.start_link([
  ...>   worker(MyServer1,[]),
  ...>   worker(MyServer2,[])
  ...> ], restart_strategy: :one_for_one, delay_fun: fn count,_id-> 200*(1 <<< count) end)

Summary

Functions

code_change(vsn, state, extra)

See :supervisor.code_change/3.

count_children(sup)

See Supervisor.count_children/1.

delete_child(sup, childid)

See Supervisor.delete_child/2.

handle_call(msg, rep_to, state)

See :supervisor.handle_call/3.

handle_cast(msg, state)

See :supervisor.handle_cast/2.

restart_child(sup, childid)

See Supervisor.restart_child/2.

start_child(supervisor, child_spec)
start_link(children, options)
start_link(module, arg, options \\ [])
stop(sup)

See Supervisor.stop/1.

stop(sup, r)

See Supervisor.stop/2.

stop(sup, r, t)

See Supervisor.stop/3.

terminate(r, s)

See :supervisor.terminate/2.

terminate_child(sup, child)

See Supervisor.terminate_child/2.

which_children(supervisor)