import { RPCMessage } from '../../constants'; import RpcHandler from './rpc-handler'; import { SimpleSocketWrapper, DeepstreamConfig } from '@deepstream/types'; /** * Relays a remote procedure call from a requestor to a provider and routes * the providers response to the requestor. Provider might either be a locally * connected SocketWrapper or a RpcProviderProxy that forwards messages * from a remote provider within the network */ export declare class Rpc { private rpcHandler; private requestor; private provider; private config; private message; private correlationId; private rpcName; private isAccepted; private acceptTimeout; private responseTimeout; /** */ constructor(rpcHandler: RpcHandler, requestor: SimpleSocketWrapper, provider: SimpleSocketWrapper, config: DeepstreamConfig, message: RPCMessage); private getRequestor; /** * Processor for incoming messages from the RPC provider. The * RPC provider is expected to send two messages, * * RPC|A|REQ|| * * and * * RPC|RES||] * * Both of these messages will just be forwarded directly * to the requestor */ handle(message: RPCMessage): void; /** * Destroys this Rpc, either because its completed or because a timeout has occured */ destroy(): void; /** * By default, a RPC is the communication between one requestor * and one provider. If the original provider however rejects * the request, deepstream will try to re-route it to another provider. * * This happens in the reroute method. This method will query * the rpc-handler for an alternative provider and - if it has * found one - call this method to replace the provider and re-do * the second leg of the rpc */ private setProvider; /** * Handles rpc acknowledgement messages from the provider. * If more than one Ack is received an error will be returned * to the provider */ private handleAccept; /** * This method handles rejection messages from the current provider. If * a provider is temporarily unable to serve a request, it can reject it * and deepstream will try to reroute to an alternative provider * * If no alternative provider could be found, this method will send a NO_RPC_PROVIDER * error to the client and destroy itself */ reroute(): void; /** * Callback if the accept message hasn't been returned * in time by the provider */ private onAcceptTimeout; /** * Callback if the response message hasn't been returned * in time by the provider */ onResponseTimeout(): void; }