import { ChannelOptions } from "../types/channel.types.mjs"; import { HealthCheckResult } from "../types/driver.types.mjs"; import { ChannelContract } from "../contracts/channel.contract.mjs"; import { EventMessage } from "../message-managers/event-message.mjs"; import { EventConsumerClass } from "../message-managers/types.mjs"; import { BrokerDriverContract } from "../contracts/broker-driver.contract.mjs"; //#region ../@warlock.js/herald/src/communicators/broker.d.ts /** * Options for creating a Broker */ interface BrokerOptions { /** Unique name for this broker */ name: string; /** The underlying driver */ driver: BrokerDriverContract; /** Whether this is the default broker */ isDefault?: boolean; } /** * Broker - wrapper around a driver with metadata * * Similar to DataSource in @warlock.js/cascade * * @example * ```typescript * const broker = new Broker({ * name: "default", * driver: rabbitMQDriver, * isDefault: true, * }); * * // Get a channel * const channel = broker.channel("user.created"); * ``` */ declare class Broker { /** Unique name identifying this broker */ readonly name: string; /** The underlying driver */ readonly driver: BrokerDriverContract; /** Whether this is the default broker */ readonly isDefault: boolean; /** * Create a new Broker * * @param options - Broker configuration */ constructor(options: BrokerOptions); /** * Subscribe the given consumer */ subscribe(consumer: EventConsumerClass): () => void; /** * Publish the given event message */ publish>(event: EventMessage): void; /** * Get or create a channel * * @param name - Channel name * @param options - Channel options * @returns Channel instance * * @example * ```typescript * // Simple channel * const channel = broker.channel("notifications"); * * // Typed channel with schema * const orderChannel = broker.channel("orders", { * schema: OrderSchema, * durable: true, * }); * ``` */ channel(name: string, options?: ChannelOptions): ChannelContract; /** * Check if the broker is connected */ get isConnected(): boolean; /** * Connect the underlying driver */ connect(): Promise; /** * Disconnect the underlying driver */ disconnect(): Promise; /** * Start consuming messages */ startConsuming(): Promise; /** * Stop consuming messages */ stopConsuming(): Promise; /** * Health check */ healthCheck(): Promise; } //#endregion export { Broker, BrokerOptions }; //# sourceMappingURL=broker.d.mts.map