Cluster
Interface: Cluster
Defined in: packages/core/src/services/cluster.service.ts:16
Instances of an application electing one leader among them
Methods
getInstanceId()
getInstanceId():
string
Defined in: packages/core/src/services/cluster.service.ts:37
Get the identity of this instance
Returns
string
the identity of this instance
isLeader()
isLeader():
boolean
Defined in: packages/core/src/services/cluster.service.ts:32
Check whether leader
Returns
boolean
whether this instance is the leader
whenLeader()
whenLeader(
fn,deregisteredFn?): () =>void
Defined in: packages/core/src/services/cluster.service.ts:27
Run fn whenever this instance becomes the leader, and deregisteredFn when it stops leading
Registering while already leader runs fn at once. The two callbacks of a registration never overlap: a
deregisteredFn waits for a pending fn.
Parameters
fn
called when this instance becomes the leader
deregisteredFn?
called when it loses the leadership, shuts down, or the registration is removed after fn
ran
Returns
a function removing the registration
() => void