Answers whether this node is the one that should arm timers.
AshWorkflow.Scheduler.Precise holds its deadlines in memory. Two nodes
holding the same timer fire the same deadline twice, so exactly one node may
arm them. This behaviour is how Precise asks which node that is, and it is
one callback so that a deployment can answer the question with whatever it
already runs.
The implementations
AshWorkflow.Scheduler.Leader.Single— always the leader. The default, correct on one node, and what every test wants.AshWorkflow.Scheduler.Leader.Oban— delegates toOban.Peer.leader?/2, which is the same electionOban.Stagergates on. Correct across a cluster, and needs an Oban instance running.
Choosing one
workflow do
scheduler {AshWorkflow.Scheduler.Precise, leader: AshWorkflow.Scheduler.Leader.Oban}
endOr with options for the implementation:
scheduler {AshWorkflow.Scheduler.Precise, leader: {AshWorkflow.Scheduler.Leader.Oban, name: MyApp.Oban}}Single is the default because a workflow running on one node should not have
to configure an election to get a timer. Precise logs a warning at boot when
it is running on Single and more than one node is connected, since that is
the configuration where deadlines fire twice.
Summary
Callbacks
Whether this node should arm timers.
Functions
Ask the configured leader implementation whether this node should arm timers.
Callbacks
Whether this node should arm timers.
Called before arming a deadline and again before firing one. An
implementation that talks to the network must not raise: return false when
it cannot tell, so that a poll picks the work up rather than two nodes racing.