@betit/orion
Version:
Pluggable microservice framework
54 lines (53 loc) • 1.32 kB
TypeScript
/**
* NATS transport.
*/
export default class NatsTransport {
private options;
private client;
private closeHandler;
/**
* Create new NATS transport.
*/
constructor(options?: any);
/**
* NATS heartbeat check based on
* https://github.com/nats-io/node-nats/issues/173
*/
heartbeat(): void;
/**
* 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 {Function} callback
*/
onClose(callback: any): void;
}