mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-26 22:39:39 +08:00
New-Types: add types for Opossum (#29637)
This commit is contained in:
34
types/opossum/index.d.ts
vendored
Normal file
34
types/opossum/index.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Type definitions for opossum 1.8
|
||||
// Project: https://github.com/bucharest-gold/opossum
|
||||
// Definitions by: Quinn Langille <https://github.com/quinnlangille>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node"/>
|
||||
import * as stream from "stream";
|
||||
|
||||
export type Action = () => any;
|
||||
|
||||
export class CircuitBreaker {
|
||||
promisify(action: Action): Promise<Action>;
|
||||
stats(): stream.Transform;
|
||||
}
|
||||
|
||||
export interface CircuitBreakerOptions {
|
||||
timeout?: number;
|
||||
maxFailures?: number;
|
||||
resetTimeout?: number;
|
||||
rollingCountTimeout?: number;
|
||||
rollingCountBuckets?: number;
|
||||
name?: string;
|
||||
rollingPercentilesEnabled?: boolean;
|
||||
capacity?: number;
|
||||
errorThresholdPercentage?: number;
|
||||
enabled?: boolean;
|
||||
allowWarmUp?: boolean;
|
||||
}
|
||||
|
||||
export default function circuitBreaker(
|
||||
action: Action,
|
||||
options?: CircuitBreakerOptions
|
||||
): CircuitBreaker;
|
||||
24
types/opossum/opossum-tests.ts
Normal file
24
types/opossum/opossum-tests.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Transform } from "stream";
|
||||
import circuitBreaker, { CircuitBreaker, CircuitBreakerOptions } from "opossum";
|
||||
|
||||
const _blank = () => {};
|
||||
|
||||
const testNoOptions: CircuitBreaker = circuitBreaker(_blank);
|
||||
|
||||
const options: CircuitBreakerOptions = {
|
||||
timeout: 1,
|
||||
maxFailures: 1,
|
||||
resetTimeout: 1,
|
||||
rollingCountTimeout: 1,
|
||||
rollingCountBuckets: 1,
|
||||
name: "testing",
|
||||
rollingPercentilesEnabled: true,
|
||||
capacity: 1,
|
||||
errorThresholdPercentage: 1,
|
||||
enabled: true,
|
||||
allowWarmUp: true
|
||||
};
|
||||
|
||||
const testWithOptions: CircuitBreaker = circuitBreaker(_blank, options);
|
||||
const shouldBeAPromise: Promise<any> = testWithOptions.promisify(_blank);
|
||||
const shouldBeATransformStream: Transform = testWithOptions.stats();
|
||||
23
types/opossum/tsconfig.json
Normal file
23
types/opossum/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",
|
||||
"opossum-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/opossum/tslint.json
Normal file
1
types/opossum/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user