export = ClusterSubscriber; declare class ClusterSubscriber { /** * @constructor * @param {ClusterNode} localNode * @param {string} remoteNodeId - Remote node unique ID * @param {string} remoteNodeIP - address of the distant node */ constructor(localNode: ClusterNode, remoteNodeId: string, remoteNodeIP: string); localNode: ClusterNode; remoteNodeIP: string; remoteNodeAddress: string; remoteNodeId: string; remoteNodeEvictionPrevented: boolean; socket: Subscriber; protoroot: protobuf.Root; lastMessageId: Long; state: 1; buffer: any[]; heartbeatTimer: NodeJS.Timeout; lastHeartbeat: number; heartbeatDelay: number; handlers: Readonly<{ AddCollection: (message: any) => void; AddIndex: (message: any) => void; ClusterWideEvent: (message: any) => void; DocumentNotification: (message: any) => void; DumpRequest: (message: any) => void; Heartbeat: () => void; InvalidateProfile: (message: any) => void; InvalidateRole: (message: any) => void; NewAuthStrategy: (message: any) => void; NewRealtimeRoom: (message: any) => void; NodeEvicted: (message: any) => void; NodePreventEviction: (message: any) => Promise; NodeShutdown: (message: any) => void; RefreshIndexCache: () => Promise; RefreshValidators: () => void; RemoveAuthStrategy: (message: any) => void; RemoveCollection: (message: any) => void; RemoveIndexes: (message: any) => void; RemoveRealtimeRoom: (message: any) => void; ResetSecurity: () => void; Shutdown: () => void; Subscription: (message: any) => void; Unsubscription: (message: any) => void; UserNotification: (message: any) => void; }>; logger: import("../kuzzle/Logger").Logger; /** * Initializes this class, establishes a connection to the remote node and * starts listening to it. */ init(): Promise; /** * Starts subscribing to other nodes * Do NOT wait this method: it's an infinite loop, it's not meant to ever * return (unless the remote node has been evicted) */ listen(): Promise; /** * Plays all buffered sync messages, and switches this subscriber state from * BUFFERING to SANE. * * @param {Long} lastMessageId * @return {void} */ sync(lastMessageId: Long): void; /** * Decodes an incoming message, and dispatches it. * The topic name must match a protobuf message. * * /!\ This method MUST NEVER THROW * It's awaited by this.listen(), which cannot be awaited (infinite loop), * and it also cannot afford to attach a rejection handler everytime a message * is received to prevent clogging the event loop with unnecessary promises * * @param {string} topic * @param {Buffer} data * @return {void} */ processData(topic: string, data: Buffer): void; handleNodePreventEviction(message: any): Promise; /** * Handles a heartbeat from the remote node * * @return {void} */ handleHeartbeat(): void; /** * Handles a node eviction message. * * @param {Object} message - decoded NodeEvicted protobuf message * @return {void} */ handleNodeEviction(message: any): void; /** * Handles a node shutdown. * * @param {Object} message - decoded NodeShutdown protobuf message * @return {void} */ handleNodeShutdown(message: any): void; /** * Handles messages about realtime room creations * * @param {Object} message - decoded NewRealtimeRoom protobuf message * @return {void} */ handleNewRealtimeRoom(message: any): void; /** * Handles messages about realtime subscriptions * * @param {Object} message - decoded Subscription protobuf message * @return {void} */ handleSubscription(message: any): void; /** * Handles messages about realtime room removal * * @param {Object} message - decoded RemoveRealtimeRoom protobuf message * @return {void} */ handleRealtimeRoomRemoval(message: any): void; /** * Handles messages about user unsubscriptions * * @param {Object} message - decoded Unscription protobuf message * @return {void} */ handleUnsubscription(message: any): void; /** * Handles messages about cluster-wide events * * @param {Object} message - decoded ClusterWideEvent protobuf message * @return {void} */ handleClusterWideEvent(message: any): void; /** * Handles messages about document notifications * * @param {Object} message - decoded DocumentNotification protobuf message * @return {void} */ handleDocumentNotification(message: any): void; /** * Handles messages about user notifications * * @param {Object} message - decoded UserNotification protobuf message * @return {void} */ handleUserNotification(message: any): void; /** * Handles messages about new authentication strategies * * @param {Object} message - decoded NewAuthStrategy protobuf message * @return {void} */ handleNewAuthStrategy(message: any): void; /** * Handles messages about authentication strategy removals * * @param {Object} message - decoded RemoveAuthStrategy protobuf message * @return {void} */ handleAuthStrategyRemoval(message: any): void; /** * Handles messages about security resets * * @return {void} */ handleResetSecurity(): void; /** * Handles a cross-nodes dump request * * @param {Object} message - decoded DumpRequest protobuf message * @return {void} */ handleDumpRequest(message: any): void; /** * Handles cluster-wide shutdown * @return {void} */ handleShutdown(): void; /** * Handles changes on document validators * * @return {void} */ handleRefreshValidators(): void; /** * Handles manual refresh of the index cache */ handleRefreshIndexCache(): Promise; /** * Invalidates a profile to force reloading it from the storage space * * @param {Object} message - decoded DumpRequest protobuf message * @return {void} */ handleProfileInvalidation(message: any): void; /** * Invalidates a role to force reloading it from the storage space * * @param {Object} message - decoded DumpRequest protobuf message * @return {void} */ handleRoleInvalidation(message: any): void; /** * Adds a new index to the index cache * * @param {Object} message - decoded IndexCacheAdd protobuf message * @return {void} */ handleIndexAddition(message: any): void; /** * Removes indexes from the index cache * * @param {Object} message - decoded IndexCacheAdd protobuf message * @return {void} */ handleIndexesRemoval(message: any): void; /** * Adds a new collection to the index cache * * @param {Object} message - decoded IndexCacheAdd protobuf message * @return {void} */ handleCollectionAddition(message: any): void; /** * Removes a collection from the index cache * * @param {Object} message - decoded IndexCacheAdd protobuf message * @return {void} */ handleCollectionRemoval(message: any): void; /** * Checks that we did receive a heartbeat from the remote node * If a heartbeat is missing, we allow 1 heartbeat round for the remote node * to recover, otherwise we evict it from the cluster. */ checkHeartbeat(): Promise; /** * Disconnects from the remote node, and frees all allocated resources. */ dispose(): void; /** * Checks that the received message is the one we expect. * @param {Object} message - decoded protobuf message * @return {boolean} false: the message must be discarded, true otherwise */ validateMessage(message: any): boolean; evictNode({ broadcast, reason }: { broadcast: any; reason: any; }): Promise; } declare namespace ClusterSubscriber { export { stateEnum }; } import { Subscriber } from "zeromq"; import protobuf = require("protobufjs"); import Long = require("long/umd/types"); declare const stateEnum: Readonly<{ BUFFERING: 1; SANE: 2; MISSING_HEARTBEAT: 3; EVICTED: 4; }>;