Beethoven.CoreServer behaviour (Beethoven v0.3.3)
Core Service for Beethoven. Watches other nodes within the cluster and cascade updates across the beethoven PIDs as needed.
External API calls
These are calls that can be made from external servers
alert_me/1
-> Alerts the caller on cluster node changes. (see 'Listening for cluster node changes' for more info.)new_node/1
-> Adds node to CoreServer state mnesia table. (Should be called by theListener
server)get_mode/0
-> Returns the mode of the CoreServer. (:standalone | :clustered)
Listening for cluster node changes
Using alert_me/1
from a local client, you can tell the CoreServer to call you back when there is a change to a cluster node.
Ignores changes to itself, only delivers updates of other nodes.
To use this, the caller must implement the CoreServer
behavior and callback node_update/2
.
Once a change occurs, the CoreServer will call the callback function for the following module/process.
node_update/2
should contain the logic needed when a node changes state.
Summary
Types
Possible status(s) for nodes within Beethoven.
Possible statuses for CoreServer
Single tracker event from the Mnesia table
A single row in the CoreServer tracker.
Callbacks
Callback needed for downlevel services to streamline receiving node down updates.
Functions
Adds a node to Mnesia cluster
Tell the local CoreServer that we want to be alerted to changes to cluster node state.
Returns a specification to start this module under a supervisor.
Callback for entry when we are in :standalone or :clustered mode
Gets mode from the CoreServer.
Callback to handle casts for services that need updates on node state.
Add a node to the Cluster Node tracker.
If node is already tracked, it will be marked as :online
.
Callback implementation for Beethoven.CoreServer.node_update/2
.
Supervisor Entry point.
Types
@type nodeStatus() :: :online | :offline
Possible status(s) for nodes within Beethoven.
Options
:online
:offline
@type serverStatus() :: :standalone | :clustered
Possible statuses for CoreServer
@type trackerEvent() :: {opType :: :write | :delete, mod :: module(), new_row :: trackerRow(), old_rows :: [trackerRow()], pid_struct :: any()}
Single tracker event from the Mnesia table
@type trackerRow() :: {mod :: module(), nodeName :: node(), status :: nodeStatus(), lastChange :: DateTime.t()}
A single row in the CoreServer tracker.
Callbacks
@callback node_update(nodeName :: node(), status :: nodeStatus()) :: :ok
Callback needed for downlevel services to streamline receiving node down updates.
Required if you follow core server for cluster updates via alert_me/1
Functions
@spec add_node_to_mnesia(node()) :: :ok
Adds a node to Mnesia cluster
@spec alert_me(module()) :: :ok
Tell the local CoreServer that we want to be alerted to changes to cluster node state.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Callback for entry when we are in :standalone or :clustered mode
@spec get_mode() :: serverStatus()
Gets mode from the CoreServer.
Callback to handle casts for services that need updates on node state.
@spec new_node(node()) :: :ok
Add a node to the Cluster Node tracker.
If node is already tracked, it will be marked as :online
.
Callback implementation for Beethoven.CoreServer.node_update/2
.
@spec start_link(serverStatus()) :: GenServer.on_start()
Supervisor Entry point.