import { RequestData } from "../pipeline/common"; import { EventData } from "./messageBus"; /** * Async actions dispatcher * Connect only instances of a same service * * @export * @interface IActionBusAdapter */ export interface IActionBusAdapter { /** * Open bus * */ open(): Promise; /** * Gracefully stop message consumption */ stopReception(): any; /** * Publish an async action * * @param {string} domain * @param {string} serviceId * @param {RequestData} command */ publishTask(domain: string, serviceId: string, command: RequestData): any; /** * Consume an async action * * @param {string} domain * @param {string} serviceId * @param {Function} handler * * @memberOf IActionBusAdapter */ consumeTask(domain: string, serviceId: string, handler: (event: RequestData) => void): any; } /** * Global event bus * Events are shared by all service instance. * Event is sent when action complete * * @export * @interface IEventBusAdapter */ export interface IEventBusAdapter { /** * Open bus */ open(): any; /** * Gracefully stop message consumption */ stopReception(): any; /** * send event */ sendEvent(domain: string, event: EventData): any; /** * Consume events */ consumeEvents(domain: string, handler: (event: EventData) => void, distributionKey?: string): any; }