hamok
Version:
Lightweight Distributed Object Storage on RAFT consensus algorithm
48 lines • 1.54 kB
TypeScript
import { HamokMessage } from './HamokMessage';
export type PendingRequestConfig = {
readonly requestId: string;
timeoutInMs?: number;
neededResponses?: number;
remotePeers?: ReadonlySet<string>;
storageId?: string;
};
export type PendingRequestState = 'pending' | 'resolved' | 'rejected';
export declare class PendingRequest {
readonly config: PendingRequestConfig;
readonly responses: Map<string, HamokMessage>;
private _postponeTimeout;
private _state;
private _receivedResponses;
private _timer?;
private _promise;
private _resolve?;
private _reject?;
constructor(config: PendingRequestConfig);
get id(): string;
get completed(): boolean;
get state(): PendingRequestState;
get promise(): Promise<HamokMessage[]>;
accept(message: HamokMessage): void;
/**
* Explicitly reject the pending request if it is in the pending state
* @param reason
* @returns
*/
reject(reason: string): void;
/**
* Explicitly resolve the pending request if it is in the pending state
* @returns
*/
resolve(): void;
/**
* Check if the pending request can be resolved or not
* This is automatically called after any message accepted, but if the endpoints changed or
* some other external event happened it can be called explicitly.
* @returns
*/
refresh(): void;
private get isReady();
postponeTimeout(): void;
get [Symbol.toStringTag](): string;
}
//# sourceMappingURL=PendingRequest.d.ts.map