UNPKG

ziron-worker

Version:
46 lines (45 loc) 1.64 kB
import { WorkerServerOptions } from "./WorkerServerOptions"; import StateClient from "./StateClient"; import { Server, Socket } from "ziron-server"; import BrokerClientPool from "./externalBroker/BrokerClientPool"; export default class WorkerServer<ES extends Socket = Socket> extends Server<{ 'sharedChange': [any]; 'leadershipChange': [boolean]; 'brokerClientsUpdate': []; }, ES> { private readonly _rawJoinToken; private readonly brokerClusterClientMaxPoolSize; private readonly clusterJoinPayload; private readonly clusterShared; private readonly clusterShareAuth; readonly joinToken: { secret: string; uri: string; }; readonly stateClient?: StateClient; private readonly brokerClusterClient?; private readonly _logger; get leader(): boolean; get shared(): any; /** * @description * Provides limited access to the client pool for each broker. * Use it only when you know what you are doing. * Important: do not use any destroyed client pool * (can be checked with the destroyed property); otherwise, you risk a memory leak. */ get brokerClients(): BrokerClientPool[]; constructor(options?: WorkerServerOptions); isConnectedToState(): boolean; join(): Promise<void | undefined>; listen(): Promise<void>; joinAndListen(): Promise<void>; private _setUpStateClient; /** * Terminates the worker. * After termination, you should not use this instance anymore * or anything else from the worker. * [Use this method only when you know what you do.] */ terminate(): void; }