mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
curcuit-breaker-js: introduce @types/curcuit-breaker-js
This commit is contained in:
parent
10148d8d11
commit
7c9424cf24
12
types/circuit-breaker-js/circuit-breaker-js-tests.ts
Normal file
12
types/circuit-breaker-js/circuit-breaker-js-tests.ts
Normal file
@ -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();
|
||||
38
types/circuit-breaker-js/index.d.ts
vendored
Normal file
38
types/circuit-breaker-js/index.d.ts
vendored
Normal file
@ -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;
|
||||
}
|
||||
23
types/circuit-breaker-js/tsconfig.json
Normal file
23
types/circuit-breaker-js/tsconfig.json
Normal file
@ -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"
|
||||
]
|
||||
}
|
||||
1
types/circuit-breaker-js/tslint.json
Normal file
1
types/circuit-breaker-js/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user