@betit/orion
Version:
Pluggable microservice framework
48 lines (47 loc) • 1.22 kB
TypeScript
import { ServiceOptions } from '../types/interfaces';
/**
* Provides an interface to create your service and register request handlers.
*/
export default class Service {
name: string;
private options;
id: string;
private codec;
private transport;
/**
* Create new service.
*/
constructor(name: string, options?: ServiceOptions);
/**
* Publish to a topic.
* @param {any} topic
* @param {Object} message
*/
emit(topic: string, message: any): void;
/**
* Subscribe to a topic.
* @param {string} topic
* @param {Function} callback
*/
on(topic: string, callback: Function, disableGroup?: boolean): any;
/**
* Register request handler method.
* @param {string} method
* @param {Function} callback
* @param {string} [prefix]
*/
handle(path: string, callback: Function, prefix?: string): void;
/**
* Start listenning on the underlying transport connection.
* @param {Function} callback
*/
listen(callback: Function): void;
/**
* Close underlying transport connection.
*/
close(): void;
/**
* Service name and id.
*/
toString(): string;
}