///
///
import { ChildProcess } from 'child_process';
export interface RPCRequest
{
type: 'rpc-request';
id: string;
procedure: P;
args: A;
}
export interface RPCResponse, D extends object> {
type: 'rpc-response';
id: string;
procedure: R['procedure'];
request: R;
err?: any;
data: D;
}
export declare type RPC = RPCResponse, D>;
export interface RPCProcessOptions {
readonly name?: string;
readonly timeout?: number;
}
export declare class RPCProcess {
readonly name: string;
readonly timeout: number;
protected responseProcedures: Map Promise>;
protected proc?: ChildProcess;
constructor({ name, timeout }?: RPCProcessOptions);
start(proc: ChildProcess | NodeJS.Process): void;
register>(procedure: R['procedure'], fn: (args: R['request']['args']) => Promise): void;
call>(procedure: R['procedure'], args: R['request']['args']): Promise;
end(): void;
}
export declare class RPCHost {
readonly modulePath: string;
readonly args: readonly string[];
protected rpc: RPCProcess;
constructor(modulePath: string, args: readonly string[]);
start(): void;
register>(procedure: R['procedure'], fn: (args: R['request']['args']) => Promise): void;
call>(procedure: R['procedure'], args: R['request']['args']): Promise;
end(): void;
}