import { DeepstreamServices, DeepstreamConfig, ClusterRegistry, DeepstreamPlugin } from '@deepstream/types'; /** * This class maintains a list of all nodes that are * currently present within the cluster. * * It provides status messages on a predefined interval * and keeps track of incoming status messages. */ export declare class DistributedClusterRegistry extends DeepstreamPlugin implements ClusterRegistry { private pluginOptions; private services; private config; description: string; private inCluster; private nodes; private leaderScore; private publishInterval; private checkInterval; private role; private emitter; /** * Creates the class, initialises all intervals and publishes the * initial status message that notifies other nodes within this * cluster of its presence. */ constructor(pluginOptions: any, services: Readonly, config: Readonly); init(): void; close(): Promise; onServerAdded(callback: (serverName: string) => void): void; onServerRemoved(callback: (serverName: string) => void): void; /** * Returns the serverNames of all nodes currently present within the cluster */ getAll(): string[]; /** * Returns true if this node is the cluster leader */ isLeader(): boolean; /** * Returns the name of the current leader */ getLeader(): string; /** * Distributes incoming messages on the cluster topic */ private onMessage; /** * Called on an interval defined by clusterActiveCheckInterval to check if all nodes * within the cluster are still alive. * * Being alive is defined as having received a status message from that node less than * milliseconds ago. */ private checkNodes; /** * Updates the status of a node with incoming status data and resets its lastStatusTime. * * If the remote node doesn't exist yet, it is added and an add event is emitted / logged */ private updateNode; /** * Removes a remote node from this registry if it exists. * Logs/emits remove */ private removeNode; /** * Publishes this node's status on the message bus */ private publishStatus; /** * Prompts this node to leave the cluster, either as a result of a server.close() * call or due to the process exiting. * This sends out a leave message to all other nodes and destroys this class. */ private leaveCluster; }