import type { Authenticator } from "./auth.js"; import type { PeerState } from "./gossip.js"; export type { PeerState, PeerStatus } from "./gossip.js"; import { GossipUDP } from "./gossip_udp.js"; import { EventEmitter } from "node:events"; export interface GossipOptions { /** Interval in ms to send gossip messages. */ gossipIntervalMs: number; /** Interval in ms to run the failure detection loop. */ cleanupIntervalMs: number; /** Time in ms after which a peer is considered dead if no updates are received. */ failureTimeoutMs: number; /** Number of random peers to send gossip to. */ gossipFanout: number; /** List of seed nodes (UDP addresses) to connect to initially. */ seedNodes: string[]; } export declare class GossipProtocol extends EventEmitter { private readonly gossipUDP; private readonly options; private readonly auth?; private self; private peers; private gossipIntervalTimer?; private cleanupIntervalTimer?; private _isLeaving; private readonly log; private hasWarnedOpenModeReceive; constructor(nodeId: string, rpcAddress: string, // ZeroMQ address gossipAddress: string, // UDP address (e.g., 127.0.0.1:6000) gossipUDP: GossipUDP, options: GossipOptions, auth?: Authenticator | undefined, roles?: string[]); /** * Sets a custom metadata key-value pair that will be propagated via gossip. */ setMetadata(key: string, value: string): void; /** * Gets a metadata value for this node. */ getMetadata(key: string): string | undefined; /** * Gets a metadata value for a specific peer. */ getPeerMetadata(nodeId: string, key: string): string | undefined; /** * Returns true if this node is in the process of leaving the cluster. */ isLeaving(): boolean; getNodeId(): string; start(): Promise; stop(): Promise; /** * Gracefully leaves the cluster by notifying peers before stopping. * This broadcasts a "leaving" status to all known peers, giving them * a chance to update their membership views before this node goes offline. * @param broadcastCount Number of times to broadcast leave message. Default: 3 * @param intervalMs Interval between broadcasts in ms. Default: 100 */ leave(broadcastCount?: number, intervalMs?: number): Promise; /** * Broadcasts current state to all known peers. */ private _broadcastToAllPeers; getLivePeers(): PeerState[]; getAllKnownPeers(): PeerState[]; private gossipLoop; private sendGossipMessage; private handleGossipMessage; private failureDetectionLoop; private shuffleArray; } //# sourceMappingURL=gossip_protocol.d.ts.map