UNPKG

node-cluster-ipc

Version:

A lightweight for Inter-Process Communication (IPC) between master and worker processes using the cluster module

26 lines (25 loc) 817 B
import { Worker } from 'cluster'; import { EventEmitter } from 'events'; interface ClusterIpcOptions { requestTimeout?: number; } export declare class ClusterIpc extends EventEmitter { private options; private workerIndex; private workerMap; private pendingRequests; constructor(options?: ClusterIpcOptions); get isPrimary(): boolean; get isWorker(): boolean; get worker(): Worker | undefined; get workers(): NodeJS.Dict<Worker> | undefined; send(channel: string, data: any, workerId?: number | string): void; publish(channel: string, data: any): void; request(channel: string, data: any, workerId?: number | string): Promise<any>; private reply; private setupPrimary; private setupWorker; private handleMessage; private getWorker; } export {};