mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 08:17:05 +00:00
Merge pull request #24569 from DeTeam/circuit-breaker-js
Added typings for curcuit-breaker-js
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import CircuitBreaker = require('circuit-breaker-js');
|
||||
|
||||
const breaker = new CircuitBreaker();
|
||||
breaker.isOpen();
|
||||
|
||||
const options: CircuitBreaker.Options = {};
|
||||
|
||||
let status: number = CircuitBreaker.CLOSED;
|
||||
status = CircuitBreaker.OPEN;
|
||||
|
||||
breaker.forceOpen();
|
||||
breaker.forceClose();
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
// Type definitions for circuit-breaker-js 0.0
|
||||
// Project: http://yammer.github.io/circuit-breaker-js/
|
||||
// Definitions by: Timur Amirov <https://github.com/DeTeam>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = CircuitBreaker;
|
||||
|
||||
declare namespace CircuitBreaker {
|
||||
interface Options {
|
||||
windowDuration?: number;
|
||||
numBuckets?: number;
|
||||
timeoutDuration?: number;
|
||||
errorThreshold?: number;
|
||||
volumeThreshold?: number;
|
||||
|
||||
onCircuitOpen?: (m: Metrics) => void;
|
||||
onCircuitClose?: (m: Metrics) => void;
|
||||
}
|
||||
|
||||
interface Metrics {
|
||||
totalCount: number;
|
||||
errorCount: number;
|
||||
errorPercentage: number;
|
||||
}
|
||||
}
|
||||
|
||||
declare class CircuitBreaker {
|
||||
static OPEN: 0;
|
||||
static HALF_OPEN: 1;
|
||||
static CLOSED: 2;
|
||||
|
||||
constructor(options?: CircuitBreaker.Options);
|
||||
run(command: () => void, fallback?: () => void): void;
|
||||
forceClose(): void;
|
||||
forceOpen(): void;
|
||||
unforce(): void;
|
||||
isOpen(): boolean;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"circuit-breaker-js-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user