ziron-worker
Version:
53 lines (52 loc) • 1.93 kB
TypeScript
import { ExternalBrokerClient } from "ziron-server";
import StateClient from "../StateClient";
import BrokerClientPool from "./BrokerClientPool";
import EventEmitter from "emitix";
import { InternalBroker } from "ziron-server";
type LocalEventEmitter = EventEmitter<{
'brokerClientPoolsUpdate': [];
'error': [Error];
}>;
export default class BrokerClusterClient implements ExternalBrokerClient {
private _brokerUris;
private _brokerClientMap;
private readonly _stateClient;
private readonly _internalBroker;
private readonly _mapper;
private readonly _joinTokenSecret;
private readonly _maxClientPoolSize;
private readonly _localEmitter;
readonly once: LocalEventEmitter['once'];
readonly on: LocalEventEmitter['on'];
readonly off: LocalEventEmitter['off'];
private readonly _emit;
constructor(stateClient: StateClient, internalBroker: InternalBroker, options: {
joinTokenSecret: string;
maxClientPoolSize: number;
});
/**
* @description
* Returns all broker client pools.
* Important: do not use any destroyed client pool
* (can be checked with the destroyed property); otherwise, you risk a memory leak.
*/
get brokerClients(): BrokerClientPool[];
private _setBrokerUris;
private _processClientPoolPublishEvent;
private _handleClientPoolError;
private static _getClientPoolSize;
getCurrentSubscriptions(includePending?: boolean): string[];
private updateToBrokerUris;
private _getMappedSubscriptions;
private _selectBrokerFromChannel;
private _selectClientPoolFromChannel;
private _tryWaitForClientPoolsUpdate;
publish(channel: string, data: any, processComplexTypes: boolean): void;
subscribe(channel: string): void;
unsubscribe(channel: string): void;
/**
* [Use this method only when you know what you do.]
*/
terminate(): void;
}
export {};