UNPKG

syntropylog

Version:

An instance manager with observability for Node.js applications

28 lines (27 loc) 1.56 kB
/** * @file src/utils/createFailingClient.ts * @description Factory functions for creating "failing" clients. * These clients are used as placeholders when the initialization of a real * client fails. Instead of the application crashing when getting the * client, it will fail in a controlled manner with a clear message upon * attempting to use it. */ import { IBeaconRedis } from '../redis/IBeaconRedis'; import { ILogger } from '../logger'; import { InstrumentedHttpClient } from '../http/InstrumentedHttpClient'; /** * Creates a failing placeholder for an `IBeaconRedis` client. * @param {string} instanceName - The name of the Redis instance that failed to initialize. * @param {Error} initializationError - The original error that caused the initialization to fail. * @param {ILogger} logger - The logger instance. * @returns {IBeaconRedis} An `IBeaconRedis` compliant object that will fail on every command. */ export declare function createFailingRedisClient(instanceName: string, initializationError: Error, logger: ILogger): IBeaconRedis; /** * Creates a failing placeholder for an `InstrumentedHttpClient`. * @param {string} instanceName - The name of the HTTP client instance that failed. * @param {string} type - The type of the HTTP client (e.g., 'AxiosAdapter'). * @param {ILogger} logger - The logger instance. * @returns {InstrumentedHttpClient} A client object that will fail on every method call. */ export declare function createFailingHttpClient(instanceName: string, type: string, logger: ILogger): InstrumentedHttpClient;