import { AppInstanceType } from '../App'; import { MessageBodies, MessageKeys, MessagesUnion, Message, MessageInfoOmitFrom } from '../utils/message'; /** * 一方向性のリスト同期 * Masterからは各Instanceへ分割されたリストを同期 * Slaveからはping情報の送信のみ * Cassandraと同じく「時間が経てば正しくなる」方式を採用。 */ export declare abstract class Adaptor { instanceType: AppInstanceType; id: string; isReady: boolean; isShutdown: boolean; onReportRequest?: (masterName: string) => Promise; onKeyRequest?: (masterName: string, requestId: string, key: string, obnizId?: string) => Promise; onKeyRequestResponse?: (requestId: string, instanceName: string, results: { [key: string]: string; }) => Promise; /** * Fired on a Slave when another Slave sends a worker-to-worker request. */ onWorkerKeyRequest?: (fromInstanceName: string, requestId: string, key: string, obnizId?: string) => Promise; /** * Fired on a Slave when another Slave responds to a worker-to-worker request * that was issued from this Slave. */ onWorkerKeyRequestResponse?: (requestId: string, fromInstanceName: string, results: { [key: string]: string; }) => Promise; onSynchronize?: (options: MessageBodies['synchronize']) => Promise; onReported?: (instanceName: string, installIds: string[]) => Promise; constructor(id: string, instanceType: AppInstanceType); protected _onReady(): void; onMessage(mes: MessagesUnion): Promise; protected _onSlaveMessage(mes: MessagesUnion): Promise; protected _onManagerMessage(mes: MessagesUnion): Promise; reportRequest(): Promise; report(installIds: string[], masterName?: string): Promise; keyRequest(key: string, requestId: string): Promise; directKeyRequest(obnizId: string, instanceName: string, key: string, requestId: string): Promise; keyRequestResponse(masterName: string, requestId: string, results: { [key: string]: string; }): Promise; workerKeyRequest(key: string, requestId: string): Promise; directWorkerKeyRequest(obnizId: string, key: string, requestId: string): Promise; workerKeyRequestResponse(toInstanceName: string, requestId: string, results: { [key: string]: string; }): Promise; synchronizeRequest(options: MessageBodies['synchronize']): Promise; protected _sendMessage(action: ActionName, info: MessageInfoOmitFrom, data: Message['body']): Promise; protected abstract _onSendMessage(data: MessagesUnion): Promise; /** * Returns the number of Slave instances currently reachable on the bus. * Used by Slave.workerRequest() to early-resolve a broadcast once every * expected instance has replied, without waiting for the full timeout. * * Master instances include a Slave part and are counted here as well. * Adaptors that cannot enumerate peers should return 0; callers will * then fall back to waiting the full timeout. */ getSlaveInstanceCount(): Promise; shutdown(): Promise; protected abstract onShutdown(): Promise; }