UNPKG

syntropylog

Version:

An instance manager with observability for Node.js applications

40 lines (39 loc) 1.55 kB
/** * FILE: src/brokers/BrokerManager.ts * DESCRIPTION: * Manages the lifecycle and creation of multiple instrumented broker client instances, * following the same pattern as HttpManager and RedisManager. */ import { IContextManager } from '../context'; import { SyntropyBrokerConfig } from '../config'; import { ILogger } from '../logger'; import { InstrumentedBrokerClient } from './InstrumentedBrokerClient'; /** * @interface BrokerManagerOptions * @description Defines the options required to initialize the BrokerManager. */ export interface BrokerManagerOptions { /** The main application configuration. */ config: SyntropyBrokerConfig; /** The factory for creating logger instances. */ loggerFactory: ILogger; /** The manager for handling asynchronous contexts. */ contextManager: IContextManager; } /** * @class BrokerManager * @description Manages the lifecycle and creation of multiple instrumented broker client instances. * It reads the configuration, creates an `InstrumentedBrokerClient` for each defined * instance, and provides a way to retrieve them and shut them down gracefully. */ export declare class BrokerManager { private readonly instances; private defaultInstance?; private readonly logger; private readonly config; private readonly contextManager; constructor(config: SyntropyBrokerConfig, logger: ILogger, contextManager: IContextManager); init(): Promise<void>; getInstance(name?: string): InstrumentedBrokerClient; shutdown(): Promise<void>; }