import { LeaderServiceOptions } from './leader';
export type MeshMessageMap = Record<string, {
    request: unknown;
    response: unknown;
}>;
export interface MeshNode {
    instanceId: number;
    hostname: string;
    self: boolean;
}
export interface MeshServiceOptions {
    heartbeatIntervalMs?: number;
    nodeTtlMs?: number;
    requestTimeoutMs?: number;
    leaderOptions?: LeaderServiceOptions;
}
export declare class MeshRequestTimeoutError extends Error {
    constructor(instanceId: number, type: string);
}
export declare class MeshHandlerError extends Error {
    constructor(message: string);
}
export declare class MeshNoHandlerError extends Error {
    constructor(type: string);
}
export declare class MeshService<T extends MeshMessageMap> {
    private _instanceId;
    private key;
    private prefix;
    private running;
    private heartbeatIntervalMs;
    private nodeTtlMs;
    private requestTimeoutMs;
    private leaderOptions?;
    private heartbeatTimer;
    private leaderService;
    private subscriberClient;
    private handlers;
    private pendingRequests;
    private activeHandlerIntervals;
    private nodeCleanedUpCallback;
    private logger;
    constructor(key: string, options?: MeshServiceOptions);
    get instanceId(): number;
    registerHandler<K extends keyof T & string>(type: K, handler: (data: T[K]['request']) => T[K]['response'] | Promise<T[K]['response']>): void;
    setNodeCleanedUpCallback(cb: (instanceId: number) => void | Promise<void>): void;
    getNodes(): Promise<MeshNode[]>;
    invoke<K extends keyof T & string>(instanceId: number, type: K, data: T[K]['request']): Promise<T[K]['response']>;
    start(): Promise<void>;
    stop(): Promise<void>;
    private nextIdKey;
    private heartbeatsKey;
    private nodesKey;
    private channelForInstance;
    private doHeartbeat;
    private doCleanup;
    private handleMessage;
    private handleHeartbeatMessage;
    private handleResponseMessage;
    private handleRequestMessage;
}
export declare type __ΩMeshMessageMap = any[];
export declare type __ΩMeshNode = any[];
export declare type __ΩMeshServiceOptions = any[];
//# sourceMappingURL=mesh.d.ts.map