diff --git a/src/event-bus/index.ts b/src/event-bus/index.ts index 96fbe600e55729c36f4bf28d0436b6dc420881c7..3067e7534c483db021b200f2c271bbf4327aaef1 100644 --- a/src/event-bus/index.ts +++ b/src/event-bus/index.ts @@ -1,43 +1,2 @@ -// Abstract Message Queue - types and interfaces - -/** - * TODO: Once agreed, add these to DefinitelyTyped so they can be shared. - */ - -export type EventType = string; - -export interface Event<T extends object> { - readonly eventType: EventType; - readonly id: string; // Generated when the event is emitted - readonly created: Date; - readonly payload: T; // The actual data the event is carrying. - // version: has been removed - so we can remain weakly typed - // context: has also been removed - if you need information about the origin - // source of the event then put it in the payload. -} - -export interface EventPublisher { - // Promise<boolean> should this become void | exception? we only need to know if something went wrong - publish<T extends object>(event: Event<T>): Promise<boolean>; -} - -export interface EventSubscriber { - // handler: returns whether or not we should ack the message - subscribe<T extends object>(eventType: string, handler: (event: Event<T>) => Promise<boolean>): void; -} - -export abstract class EventBus { - // register the following: - // - eventsToHandle - a list of events you will publish/subscribe to - // - serviceName - used when subscribing to generate a unique queue for holding - // incoming messages of the form: `consumer__${eventType}__${serviceName}` - constructor(readonly eventsToHandle: EventType[], readonly serviceName: string) {} - destroy(): Promise<void> { - return Promise.resolve(); - } -} - -// This isn't generic enough -export interface EventConfig { - url: string; -} +export * from './event-bus'; +export * from './types';