UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

27 lines (26 loc) 887 B
import { GeneralFunction } from "../types"; /** * TemporaryUnAvailableError * * when the circuit breaker is open (failure happened latest), will direct throw this error * * @internal please do not throw this error outside of newdash inner functions */ export declare class TemporaryUnAvailableError extends Error { /** * the error cause the function temporary not available */ causeError: Error; constructor(msg: string, causeError?: Error); } /** * fallback to circuit * * will directly raise error [[TemporaryUnAvailableError]] when some error happened before in duration * * @category Fallback * @param runner * @param openDuration default is 10000 (10 seconds) * @param cacheSize the timer & error cache size, default is 1024 */ export declare function circuit<T extends GeneralFunction>(runner: T, openDuration?: number, cacheSize?: number): T;