UNPKG

mollitia

Version:

JavaScript Resilience Library

54 lines (52 loc) 1.61 kB
import { Circuit, CircuitFunction, Logger } from '../circuit.js'; import { EventEmitter } from '../helpers/event.js'; /** * Properties that customizes the module behavior. */ export declare abstract class ModuleOptions { name?: string; active?: boolean; logger?: Logger; } /** * Array containing every module. */ export declare const modules: Module[]; /** * The Module Class, that may modifies the circuit behavior. */ export declare class Module extends EventEmitter { /** * The Module name. */ name: string; /** * Whether the Module is active or not. */ active: boolean; /** * The Module logger, for monitoring. */ logger?: Logger; constructor(options?: ModuleOptions); /** * Called when the module is executed by the circuit. * @param circuit The Circuit reference. * @param promise The Circuit function. * @param params The Eventual parameters to use with the Circuit function. * @example * // Empty code to execute the function and emit the execute event * const _exec = promise(...params); * this.emit('execute', circuit, _exec); * return _exec; */ execute<T>(circuit: Circuit, promise: CircuitFunction, ...params: any[]): Promise<T>; /** * Returns params passed to the execute method. * @param circuit The Circuit reference. * @param params The Eventual parameters to use with the Circuit function. * @example * const _params = this.getExecParams(circuit, params); */ getExecParams(circuit: Circuit, params: any[]): any[]; }