import type { BrokerDriverContract } from "../contracts"; import type { ChannelContract } from "../contracts/channel.contract"; import { EventMessage } from "../message-managers/event-message"; import { EventConsumerClass } from "../message-managers/types"; import type { ChannelOptions } from "../types"; /** * Options for creating a Broker */ export 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"); * ``` */ export 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; } //# sourceMappingURL=broker.d.ts.map