egg
Version:
A web application framework for Node.js
61 lines • 2.05 kB
TypeScript
import { IMessenger } from "./IMessenger.js";
import { EggApplicationCore } from "../../egg.js";
import { BaseMessenger } from "./base.js";
//#region src/lib/core/messenger/ipc.d.ts
/**
* Communication between app worker and agent worker by IPC channel
*/
export declare class Messenger extends BaseMessenger implements IMessenger {
#private;
readonly pid: string;
opids: string[];
constructor(egg: EggApplicationCore);
/**
* Send message to all agent and app
* @param {String} action - message key
* @param {Object} data - message value
* @return {Messenger} this
*/
broadcast(action: string, data?: unknown): Messenger;
/**
* send message to the specified process
* @param {String} workerId - the workerId of the receiver
* @param {String} action - message key
* @param {Object} data - message value
* @return {Messenger} this
*/
sendTo(workerId: string, action: string, data?: unknown): Messenger;
/**
* send message to one app worker by random
* - if it's running in agent, it will send to one of app workers
* - if it's running in app, it will send to agent
* @param {String} action - message key
* @param {Object} data - message value
* @return {Messenger} this
*/
sendRandom(action: string, data?: unknown): Messenger;
/**
* send message to app
* @param {String} action - message key
* @param {Object} data - message value
* @return {Messenger} this
*/
sendToApp(action: string, data?: unknown): Messenger;
/**
* send message to agent
* @param {String} action - message key
* @param {Object} data - message value
* @return {Messenger} this
*/
sendToAgent(action: string, data?: unknown): Messenger;
/**
* @param {String} action - message key
* @param {Object} data - message value
* @param {String} to - let master know how to send message
* @return {Messenger} this
*/
send(action: string, data: unknown | undefined, to?: string): Messenger;
onMessage(message: any): void;
close(): void;
}
//#endregion