Grains.DebugTimer (Grains v1.7.0)
Debug version of Grains.Timer
.
To replace the normal Timer with this, start you bread like this:
recipe = Recipe.new(:Periodic, %{
Source => Grains.periodic(Sink, 10, %{with_timestamps: true}),
})
grains = Grains.new(%{
Source => {Source, %{}, []},
Sink => {Sink, %{}, []},
Source.Timer.Sink => {Grains.DebugTimer, [], []}
})
{:ok, bread} = Grains.Supervisor.start_link(recipe, grains, id: Test)
debug_timer = Grains.get_name(bread, Source.Timer.Sink)
send(debug_timer, :tick)
With Timestamps
Similarly to Grains.Timer
, the debug timer accepts an option with_timestamps
. If set to
true, the :tick
must include a timestamp, which is then used when forwarding the received
message downstream. If with_timestamps
is not set, the :tick
must not include a timestamp,
and the message is forwarded as-is.
With Tags
The debug timer also accepts an option with_tag
. If set to an atom, the timer will use
pull_with_tag
instead of pull
.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Callback implementation for Grains.GenGrain.handle_pull/2
.
Callback implementation for Grains.GenGrain.handle_pull/3
.
Callback implementation for Grains.GenGrain.handle_push/3
.
Callback implementation for GenServer.init/1
.
Link to this section Functions
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
handle_pull(from, state)
Callback implementation for Grains.GenGrain.handle_pull/2
.
handle_pull(from, tag, state)
Callback implementation for Grains.GenGrain.handle_pull/3
.
handle_push(msg, from, state)
Callback implementation for Grains.GenGrain.handle_push/3
.
init(opts)
Callback implementation for GenServer.init/1
.
name(left, grain)
See Grains.Timer.name/2
.