import { IObniz } from './Obniz.interface'; import { Adaptor } from './adaptor/Adaptor'; import { Worker } from './Worker'; import { App } from './App'; import { MessageBodies } from './utils/message'; import { DeviceInfo } from './types/device'; export declare class Slave { protected readonly _adaptor: Adaptor; protected readonly _instanceName: string; protected readonly _app: App; protected _workers: { [key: string]: Worker; }; protected _interval: ReturnType | null; protected _syncing: boolean; private _workerKeyRequestExecutes; constructor(_adaptor: Adaptor, _instanceName: string, _app: App); private bindAdaptorCallbacks; protected _keyRequestProcess(masterName: string, requestId: string, key: string, obnizId?: string): Promise; /** * Handle a worker-to-worker request from another Slave. * For broadcasts (no obnizId): run onRequest on every local worker. * For direct requests (obnizId set): only respond if this Slave * actually hosts that obnizId — otherwise stay silent, so the * requester's direct-mode early-resolve only fires for the real owner. */ protected _workerKeyRequestProcess(fromInstanceName: string, requestId: string, key: string, obnizId?: string): Promise; /** * Fan out a `key` to every worker in the provided map concurrently and * collect their `onRequest` results. Running in parallel avoids the * accumulated latency of waiting on each worker sequentially. * A worker whose onRequest throws is logged and omitted from results. */ private _runOnRequestParallel; /** * Issue a worker-to-worker broadcast request. Returns results collected * from all responding Slaves, keyed by obnizId. Resolves as soon as every * reachable Slave has replied, or after `timeout` with partial results. */ workerRequest(key: string, timeout?: number): Promise<{ [key: string]: string; }>; /** * Issue a worker-to-worker direct request targeting a specific obnizId. * Resolves on first response from the Slave hosting the obnizId, or * rejects with ObnizAppTimeoutError after `timeout` if no response. */ workerDirectRequest(obnizId: string, key: string, timeout?: number): Promise<{ [key: string]: string; }>; private _generateRequestId; private _getInstallsFromRedis; /** * Receive Master Generated List and compare current apps. */ protected _synchronize(options: MessageBodies['synchronize']): Promise; protected _startOneWorker(deviceInfo: DeviceInfo): Promise; protected _startOrRestartOneWorker(deviceInfo: DeviceInfo): Promise; protected _stopOneWorker(installId: string): Promise; protected _onHeartBeat(): Promise; /** * Let Master know worker is working. */ protected _reportToMaster(masterName?: string): Promise; startSyncing(): void; onShutdown(): Promise; restartWorker(obnizId: string): Promise; }