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
See :supervisor.code_change/3
See :supervisor.handle_call/3
See :supervisor.handle_cast/2
See :supervisor.terminate/2
Functions
See Supervisor.stop/1.
See Supervisor.stop/2.
See Supervisor.stop/3.