forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hystrixjs.d.ts
148 lines (132 loc) · 5.48 KB
/
hystrixjs.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Type definitions for dragula v2.1.2
// Project: https://bitbucket.org/igor_sechyn/hystrixjs
// Definitions by: Igor Sechyn <https://github.com/igorsechyn/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path="../q/Q.d.ts"/>
///<reference path="../rx/rx.d.ts"/>
declare namespace HystrixJS {
interface HystrixProperties {
"hystrix.force.circuit.open"?: boolean,
"hystrix.force.circuit.closed"?: boolean,
"hystrix.circuit.sleepWindowInMilliseconds"?:number,
"hystrix.circuit.errorThresholdPercentage"?: number,
"hystrix.circuit.volumeThreshold"?:number,
"hystrix.circuit.volumeThreshold.forceOverride"?: boolean,
"hystrix.circuit.volumeThreshold.override"?: number,
"hystrix.execution.timeoutInMilliseconds"?: number,
"hystrix.metrics.statistical.window.timeInMilliseconds"?: number,
"hystrix.metrics.statistical.window.bucketsNumber"?: number,
"hystrix.metrics.percentile.window.timeInMilliseconds"?: number,
"hystrix.metrics.percentile.window.bucketsNumber"?: number,
"hystrix.request.volume.rejectionThreshold"?: number
}
interface HystrixConfig {
metricsPercentileWindowBuckets(): number;
circuitBreakerForceClosed(): boolean;
circuitBreakerForceOpened(): boolean;
circuitBreakerSleepWindowInMilliseconds(): number;
circuitBreakerErrorThresholdPercentage(): number;
circuitBreakerRequestVolumeThreshold(): number;
circuitBreakerRequestVolumeThresholdForceOverride(): boolean;
circuitBreakerRequestVolumeThresholdOverride(): number;
executionTimeoutInMilliseconds(): number;
metricsStatisticalWindowBuckets(): number;
metricsStatisticalWindowInMilliseconds(): number;
metricsPercentileWindowInMilliseconds(): number;
metricsPercentileWindowBuckets(): number;
requestVolumeRejectionThreshold(): number;
resetProperties(): void;
init(properties: HystrixProperties): void;
}
interface Command {
execute(...args: any[]): Q.Promise<any>;
}
interface CommandBuilder {
circuitBreakerSleepWindowInMilliseconds(value: number): CommandBuilder;
errorHandler(value: (error: any) => boolean): CommandBuilder;
timeout(value: number): CommandBuilder;
circuitBreakerRequestVolumeThreshold(value: number): CommandBuilder;
requestVolumeRejectionThreshold(value: number): CommandBuilder;
circuitBreakerForceOpened(value: boolean): CommandBuilder;
circuitBreakerForceClosed(value: boolean): CommandBuilder;
statisticalWindowNumberOfBuckets(value: number): CommandBuilder;
statisticalWindowLength(value: number): CommandBuilder;
percentileWindowNumberOfBuckets(value: number): CommandBuilder;
percentileWindowLength(value: number): CommandBuilder;
circuitBreakerErrorThresholdPercentage(value: number): CommandBuilder;
run(value: (args: any) => Q.Promise<any>): CommandBuilder;
fallbackTo(value: (...args: any[]) => Q.Promise<any>): CommandBuilder;
context(value: any): CommandBuilder;
build(): Command;
}
interface CommandFactory {
getOrCreate(commandKey: string, commandGroup?: string): CommandBuilder;
resetCache(): void;
}
interface HealthCounts {
totalCount: number;
errorCount: number;
errorPercentage: number;
}
interface CommandMetrics {
markSuccess(): void;
markRejected(): void;
markFailure(): void;
markTimeout(): void;
markShortCircuited(): void;
incrementExecutionCount(): void;
decrementExecutionCount(): void;
getCurrentExecutionCount(): number;
addExecutionTime(value: number): void;
getRollingCount(type: any): number;
getExecutionTime(percentile: any): number;
getHealthCounts(): HealthCounts;
reset(): void;
}
interface MetricsProperties {
commandKey: string,
commandGroup: string,
statisticalWindowTimeInMilliSeconds?: number,
statisticalWindowNumberOfBuckets?: number,
percentileWindowTimeInMilliSeconds?: number,
percentileWindowNumberOfBuckets?: number
}
interface MetricsFactory {
getOrCreate(config: MetricsProperties): CommandMetrics;
resetCache(): void;
getAllMetrics(): Array<CommandMetrics>;
}
interface CirctuiBreakerConfig {
circuitBreakerSleepWindowInMilliseconds: number,
commandKey: string,
circuitBreakerErrorThresholdPercentage: number,
circuitBreakerRequestVolumeThreshold: number,
commandGroup: string,
circuitBreakerForceClosed: boolean,
circuitBreakerForceOpened: boolean
}
interface CircuitBreaker {
allowRequest(): boolean;
allowSingleTest(): boolean;
isOpen(): boolean;
markSuccess(): void;
}
interface CircuitFactory {
getOrCreate(config: CirctuiBreakerConfig): CircuitBreaker;
getCache(): Array<CircuitBreaker>;
resetCache(): void;
}
interface HystrixSSEStream {
toObservable(): Rx.Observable<any>
}
}
declare var hystrixjs: {
commandFactory: HystrixJS.CommandFactory,
metricsFactory: HystrixJS.MetricsFactory,
circuitFactory: HystrixJS.CircuitFactory,
hystrixSSEStream: HystrixJS.HystrixSSEStream,
hystrixConfig: HystrixJS.HystrixConfig
};
declare module "hystrixjs" {
export = hystrixjs;
}