mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #30071 from MeruFM/master
Opossum - More functionality
This commit is contained in:
Vendored
+24
-5
@@ -1,23 +1,26 @@
|
||||
// Type definitions for opossum 1.9
|
||||
// Project: https://github.com/nodeshift/opossum
|
||||
// Definitions by: Quinn Langille <https://github.com/quinnlangille>
|
||||
// Willy Zhang <https://github.com/merufm>
|
||||
// Lance Ball <https://github.com/lance>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node"/>
|
||||
import * as stream from "stream";
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
export type Action = () => any;
|
||||
export type Action = (...args: any[]) => any;
|
||||
|
||||
export class CircuitBreaker {
|
||||
export class CircuitBreaker extends EventEmitter {
|
||||
clearCache(): void;
|
||||
close(): void;
|
||||
disable(): void;
|
||||
enable(): void;
|
||||
fallback(): CircuitBreaker;
|
||||
fire(): Promise<any>;
|
||||
healthCheck(func: () => Promise<any>, interval: number): Promise<any>;
|
||||
fallback(func?: (...args: any[]) => any): this;
|
||||
fire(...args: any[]): Promise<any>;
|
||||
healthCheck(func: (...args: any[]) => Promise<any>, interval?: number): Promise<any>;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
open(): void;
|
||||
promisify(action: Action): Promise<Action>;
|
||||
stats(): stream.Transform;
|
||||
@@ -35,6 +38,22 @@ export class CircuitBreaker {
|
||||
static readonly volumeThreshold: symbol;
|
||||
}
|
||||
|
||||
export enum Event {
|
||||
cacheHit = 'cacheHit',
|
||||
cacheMiss = 'cacheMiss',
|
||||
close = 'close',
|
||||
failure = 'failure',
|
||||
fallback = 'fallback',
|
||||
fire = 'fire',
|
||||
halfOpen = 'halfOpen',
|
||||
healthCheckFailed = 'health-check-failed',
|
||||
open = 'open',
|
||||
reject = 'reject',
|
||||
semaphoreLocked = 'semaphore-locked',
|
||||
success = 'success',
|
||||
timeout = 'timeout'
|
||||
}
|
||||
|
||||
export interface CircuitBreakerOptions {
|
||||
timeout?: number;
|
||||
maxFailures?: number;
|
||||
|
||||
Reference in New Issue
Block a user