@betit/orion-node-sdk
Version:
SDK for orion
49 lines (48 loc) • 1.24 kB
TypeScript
/**
* NATS transport.
*/
export declare class NatsTransport {
private _options?;
private _client;
private _closeHandler;
/**
* Create new NATS transport.
*/
constructor(_options?: any);
/**
* Transport listen.
*/
listen(callback: Function): void;
/**
* Publish to a topic.
*/
publish(topic: string, message: any): void;
/**
* Subscribe to a topic.
*/
subscribe(topic: string, group: string, callback: Function): number;
/**
* Unsubscribe from a topic.
*/
unsubscribe(sid: number, max?: number): void;
/**
* Transport handle.
*/
handle(route: string, group: string, callback: Function): void;
/**
* Client request.
* Nats client implements this pattern out of the box.
* Publish a request with an implicit inbox listener as the response.
* This should be treated as a subscription.
*/
request(route: string, payload: any, callback: Function, timeout?: number): void;
/**
* Close connection.
*/
close(): void;
/**
* Connection closed handler
* @param {(...args: any[]) => void} callback
*/
onClose(callback: (...args: any[]) => void): void;
}