/** * This class is used to be part of the Herald Event Consumer Manager. * It should be used to consume events from Either RabbitMQ or Kafka through Herald * * It's highly recommended using it instead of declaring manual channel namd and subscribing to event */ import { ValidationResult, type ObjectValidator } from "@warlock.js/seal"; import { ConsumedEventMessage, EventConsumerClass } from "./types"; export declare abstract class EventConsumer> { /** * Event name */ static eventName: string; private static _consumerId?; static get consumerId(): string; get eventName(): string; /** * Min version accepted to be consumed by this class */ static minVersion?: number; /** * Max version accepted to be consumed by this class */ static maxVersion?: number; /** * Payload validation to auto reject the received event before accessing it in the handle method */ schema?: ObjectValidator; /** * The method that will be called when the event is received */ abstract handle(payload: Payload, event: ConsumedEventMessage): Promise; /** * Determine whether this is accepted version to be used by this consumer */ static isAcceptedVersion(version: number): boolean; /** * Validate the given data */ validate(data: Payload): Promise; } /** * Define Consumer options */ type ConsumerOptions = { /** * Payload validation to auto reject the received event before accessing it in the handle method */ schema?: ObjectValidator; /** * Handle data */ handle: (payload: Payload, event: ConsumedEventMessage) => Promise; /** * Validate the payload before executing `handle` */ validate?: (payload: Payload) => Promise; }; /** * A shorthand to define an event consumer without declaring an entire class */ export declare function defineConsumer>(eventName: string, options: ConsumerOptions): EventConsumerClass; export {}; //# sourceMappingURL=event-consumer.d.ts.map