UNPKG

@imqueue/core

Version:

Simple JSON-based messaging queue for inter service communication

88 lines (87 loc) 2.52 kB
import { ClusterManager } from './ClusterManager'; export declare const DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS: { broadcastPort: number; broadcastAddress: string; aliveTimeoutCorrection: number; }; export interface UDPClusterManagerOptions { /** * Message queue broadcast port * * @default 63000 * @type {number} */ broadcastPort?: number; /** * Message queue broadcast address * * @default limitedBroadcastAddress * @type {number} */ broadcastAddress?: string; /** * Message queue limited broadcast address * * @default 255.255.255.255 * @type {string} */ limitedBroadcastAddress?: string; /** * Message queue alive timeout correction. Used to correct waiting time to * check if the server is alive * * @default 1000 * @type {number} */ aliveTimeoutCorrection?: number; /** * Skip messages that are broadcast by specified addresses or set to * "localhost" if you want to skip messages from "127.0.0.1" or "::1" * * @type {"local" | string[]} */ excludeHosts?: 'localhost' | string[]; /** * Allow messages that are broadcast only by specified addresses or set to * "localhost" if you want to allow messages only from "127.0.0.1" or "::1" * * @type {"local" | string[]} */ includeHosts?: 'localhost' | string[]; } /** * UDP broadcast-based cluster management implementation * * @example * ~~~typescript * const queue = new ClusteredRedisQueue('ClusteredQueue', { * clusterManagers: [new UDPBroadcastClusterManager()], * }); * ~~~ */ export declare class UDPClusterManager extends ClusterManager { private static sockets; private readonly options; private socketKey; private get socket(); private set socket(value); constructor(options?: UDPClusterManagerOptions); private static free; private listenBroadcastedMessages; private startListening; private static verifyHosts; private static processMessageOnCluster; private static processBroadcastedMessage; private static parseBroadcastedMessage; private static serverAliveWait; /** * Destroys the UDPClusterManager by closing all opened network connections * and safely destroying all blocking sockets * * @returns {Promise<void>} * @throws {Error} */ destroy(): Promise<void>; private static destroySocket; private static selectNetworkInterface; }