Stoker.Activator (stoker v0.1.2)
This GenServer is used to make sure that a process will always - and once - be active in the cluster.
The way this works is that we use the :global
naming
service as a mutex - if the name {Activator, YourModule} can be registered,
then this server runs the "correct" activator.
If it cannot be registered, this means somebody else is holding it
- so we put a monitor on the process who actually registered the name, and when it dies, we try registering instead.
On every application, its Activator (or Activators) are always started once per server, so they "idle" ones will just be waiting for their turn to take over. If a new server joins a healthy cluster, its Activator will simply be waiting.
Once achieved, the only way to lose one's :master status is by death, or disconnection from the main cluster.
TODO: Decommissioning and cluster limits
The Stoker callback
A module implementing the Stoker callback will be called when some of these events happen:
- A GenServer becomes master
- A node joins or leaves the cluster
- Every few minutes
The state
This GenServer has a state that can be queried by using the
dump/1
system call.
It contains:
module
: the Stoker module to be called back. This is the same module that the Activator is registered under.mod_state
: a provate state for the Stoker module. This state is per-machine - this means that when another node becomes :master,state
: :unk,created_at
: When this GenServer was started (even if not :master)active_from
: When this GenServer became :master, or nilpid
: The current PID, when :mastermonitor
: The monitor reference to the current :master, if not :mastercurrent_node
: The name of the current node.
Summary
Functions
Returns a specification to start this module under a supervisor.
Types
level()
@type level() :: :info | :warning | :error
Functions
build_timer(t)
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.