View Source EventStreamex.Orchestrator (EventStreamex v1.3.1)
Module responsible for launching the event streaming system.
The event streaming system cannot run at the same time in different nodes. Otherwise it would crash because of a duplicate replica slot. And if we changed the name of the replica slot for each node it would, then, duplicate all WAL events received by PostgreSQL.
This is something we don't want, thus, we have this orchestrator that will ensure only one instance of the system is running at the same time.
It will also ensure that if the master node (the one running the system) crashes or terminates, the system will be started on another node to continue processing new WAL events.
Every node runs the orchestrator. When a node starts it generates a unique identifier based on the current time and communicates that id to the other nodes.
When a node terminates a new election is run based on the lowest node identifier. Thus, all nodes will agree on the new master node.
Summary
Functions
Returns a specification to start this module under a supervisor.
Checks if the supervisor is alive.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec supervisor_alive?() :: boolean()
Checks if the supervisor is alive.
The supervisor is the event streaming system. It should be alive if the current node is the master node.