@felixgeelhaar/govee-api-client 1.1.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +160 -7
- package/dist/GoveeClient.d.ts +31 -0
- package/dist/GoveeClient.d.ts.map +1 -1
- package/dist/GoveeClient.js +33 -0
- package/dist/GoveeClient.js.map +1 -1
- package/dist/errors/GoveeApiError.d.ts +1 -1
- package/dist/errors/GoveeApiError.d.ts.map +1 -1
- package/dist/errors/GoveeApiError.js +9 -2
- package/dist/errors/GoveeApiError.js.map +1 -1
- package/dist/errors/ValidationError.d.ts +28 -0
- package/dist/errors/ValidationError.d.ts.map +1 -0
- package/dist/errors/ValidationError.js +44 -0
- package/dist/errors/ValidationError.js.map +1 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/GoveeDeviceRepository.d.ts.map +1 -1
- package/dist/infrastructure/GoveeDeviceRepository.js +26 -3
- package/dist/infrastructure/GoveeDeviceRepository.js.map +1 -1
- package/dist/infrastructure/SlidingWindowRateLimiter.d.ts +83 -0
- package/dist/infrastructure/SlidingWindowRateLimiter.d.ts.map +1 -0
- package/dist/infrastructure/SlidingWindowRateLimiter.js +218 -0
- package/dist/infrastructure/SlidingWindowRateLimiter.js.map +1 -0
- package/dist/infrastructure/index.d.ts +2 -0
- package/dist/infrastructure/index.d.ts.map +1 -1
- package/dist/infrastructure/index.js +2 -0
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/infrastructure/response-schemas.d.ts +82 -0
- package/dist/infrastructure/response-schemas.d.ts.map +1 -0
- package/dist/infrastructure/response-schemas.js +59 -0
- package/dist/infrastructure/response-schemas.js.map +1 -0
- package/dist/infrastructure/retry/IntegrationGuide.d.ts +133 -0
- package/dist/infrastructure/retry/IntegrationGuide.d.ts.map +1 -0
- package/dist/infrastructure/retry/IntegrationGuide.js +295 -0
- package/dist/infrastructure/retry/IntegrationGuide.js.map +1 -0
- package/dist/infrastructure/retry/RetryConfigPresets.d.ts +114 -0
- package/dist/infrastructure/retry/RetryConfigPresets.d.ts.map +1 -0
- package/dist/infrastructure/retry/RetryConfigPresets.js +406 -0
- package/dist/infrastructure/retry/RetryConfigPresets.js.map +1 -0
- package/dist/infrastructure/retry/RetryPolicy.d.ts +148 -0
- package/dist/infrastructure/retry/RetryPolicy.d.ts.map +1 -0
- package/dist/infrastructure/retry/RetryPolicy.js +373 -0
- package/dist/infrastructure/retry/RetryPolicy.js.map +1 -0
- package/dist/infrastructure/retry/RetryableRepository.d.ts +75 -0
- package/dist/infrastructure/retry/RetryableRepository.d.ts.map +1 -0
- package/dist/infrastructure/retry/RetryableRepository.js +142 -0
- package/dist/infrastructure/retry/RetryableRepository.js.map +1 -0
- package/dist/infrastructure/retry/RetryableRequest.d.ts +132 -0
- package/dist/infrastructure/retry/RetryableRequest.d.ts.map +1 -0
- package/dist/infrastructure/retry/RetryableRequest.js +248 -0
- package/dist/infrastructure/retry/RetryableRequest.js.map +1 -0
- package/dist/infrastructure/retry/index.d.ts +35 -0
- package/dist/infrastructure/retry/index.d.ts.map +1 -0
- package/dist/infrastructure/retry/index.js +36 -0
- package/dist/infrastructure/retry/index.js.map +1 -0
- package/dist/services/GoveeControlService.d.ts +53 -0
- package/dist/services/GoveeControlService.d.ts.map +1 -1
- package/dist/services/GoveeControlService.js +138 -12
- package/dist/services/GoveeControlService.js.map +1 -1
- package/docs/EXAMPLES.md +799 -0
- package/docs/LLM_API_REFERENCE.md +425 -0
- package/docs/TYPE_DEFINITIONS.md +803 -0
- package/package.json +25 -16
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { RateLimitError, NetworkError, GoveeApiError } from '../../errors';
|
|
2
|
+
/**
|
|
3
|
+
* Environment-specific retry configuration presets
|
|
4
|
+
*/
|
|
5
|
+
export class RetryConfigPresets {
|
|
6
|
+
/**
|
|
7
|
+
* Development environment configuration - aggressive retries for testing
|
|
8
|
+
*/
|
|
9
|
+
static development(logger) {
|
|
10
|
+
return {
|
|
11
|
+
backoff: {
|
|
12
|
+
type: 'exponential',
|
|
13
|
+
initialDelayMs: 100, // Start very fast
|
|
14
|
+
maxDelayMs: 5000, // Cap at 5 seconds
|
|
15
|
+
multiplier: 1.5, // Gentle exponential growth
|
|
16
|
+
},
|
|
17
|
+
jitter: {
|
|
18
|
+
type: 'equal',
|
|
19
|
+
factor: 0.2,
|
|
20
|
+
},
|
|
21
|
+
condition: {
|
|
22
|
+
maxAttempts: 5, // More attempts for testing
|
|
23
|
+
maxTotalTimeMs: 15000, // 15 seconds total
|
|
24
|
+
retryableStatusCodes: [400, 408, 429, 500, 502, 503, 504],
|
|
25
|
+
retryableErrorTypes: [RateLimitError, NetworkError, GoveeApiError],
|
|
26
|
+
},
|
|
27
|
+
circuitBreaker: {
|
|
28
|
+
enabled: false, // Disabled for development
|
|
29
|
+
failureThreshold: 10,
|
|
30
|
+
recoveryTimeoutMs: 5000,
|
|
31
|
+
halfOpenSuccessThreshold: 1,
|
|
32
|
+
},
|
|
33
|
+
logger,
|
|
34
|
+
enableMetrics: true,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Testing environment configuration - predictable behavior
|
|
39
|
+
*/
|
|
40
|
+
static testing(logger) {
|
|
41
|
+
return {
|
|
42
|
+
backoff: {
|
|
43
|
+
type: 'fixed',
|
|
44
|
+
initialDelayMs: 100, // Fixed delay for predictable tests
|
|
45
|
+
maxDelayMs: 100,
|
|
46
|
+
},
|
|
47
|
+
jitter: {
|
|
48
|
+
type: 'none', // No jitter for predictable timing
|
|
49
|
+
},
|
|
50
|
+
condition: {
|
|
51
|
+
maxAttempts: 3,
|
|
52
|
+
maxTotalTimeMs: 1000, // Quick for tests
|
|
53
|
+
retryableStatusCodes: [429, 502, 503, 504],
|
|
54
|
+
retryableErrorTypes: [RateLimitError, NetworkError, GoveeApiError],
|
|
55
|
+
},
|
|
56
|
+
circuitBreaker: {
|
|
57
|
+
enabled: false, // Disabled for testing
|
|
58
|
+
failureThreshold: 5,
|
|
59
|
+
recoveryTimeoutMs: 1000,
|
|
60
|
+
halfOpenSuccessThreshold: 1,
|
|
61
|
+
},
|
|
62
|
+
logger,
|
|
63
|
+
enableMetrics: false, // Disabled for cleaner test output
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Production environment configuration - conservative and reliable
|
|
68
|
+
*/
|
|
69
|
+
static production(logger) {
|
|
70
|
+
return {
|
|
71
|
+
backoff: {
|
|
72
|
+
type: 'exponential',
|
|
73
|
+
initialDelayMs: 2000, // Start with 2 seconds
|
|
74
|
+
maxDelayMs: 60000, // Cap at 1 minute
|
|
75
|
+
multiplier: 2.0, // Standard exponential backoff
|
|
76
|
+
},
|
|
77
|
+
jitter: {
|
|
78
|
+
type: 'decorrelated', // Sophisticated jitter
|
|
79
|
+
factor: 0.1,
|
|
80
|
+
},
|
|
81
|
+
condition: {
|
|
82
|
+
maxAttempts: 3, // Conservative retry count
|
|
83
|
+
maxTotalTimeMs: 180000, // 3 minutes total
|
|
84
|
+
retryableStatusCodes: [429, 502, 503, 504], // Only server errors
|
|
85
|
+
retryableErrorTypes: [RateLimitError, NetworkError, GoveeApiError],
|
|
86
|
+
},
|
|
87
|
+
circuitBreaker: {
|
|
88
|
+
enabled: true,
|
|
89
|
+
failureThreshold: 5,
|
|
90
|
+
recoveryTimeoutMs: 60000, // 1 minute recovery
|
|
91
|
+
halfOpenSuccessThreshold: 3,
|
|
92
|
+
},
|
|
93
|
+
logger,
|
|
94
|
+
enableMetrics: true,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* High-frequency operations configuration - optimized for frequent API calls
|
|
99
|
+
*/
|
|
100
|
+
static highFrequency(logger) {
|
|
101
|
+
return {
|
|
102
|
+
backoff: {
|
|
103
|
+
type: 'linear',
|
|
104
|
+
initialDelayMs: 500,
|
|
105
|
+
maxDelayMs: 5000,
|
|
106
|
+
},
|
|
107
|
+
jitter: {
|
|
108
|
+
type: 'full',
|
|
109
|
+
factor: 0.5, // High jitter to spread load
|
|
110
|
+
},
|
|
111
|
+
condition: {
|
|
112
|
+
maxAttempts: 2, // Quick failure for high frequency
|
|
113
|
+
maxTotalTimeMs: 10000, // 10 seconds max
|
|
114
|
+
retryableStatusCodes: [429, 503, 504],
|
|
115
|
+
retryableErrorTypes: [RateLimitError, NetworkError],
|
|
116
|
+
},
|
|
117
|
+
circuitBreaker: {
|
|
118
|
+
enabled: true,
|
|
119
|
+
failureThreshold: 3, // Quick circuit opening
|
|
120
|
+
recoveryTimeoutMs: 15000,
|
|
121
|
+
halfOpenSuccessThreshold: 2,
|
|
122
|
+
},
|
|
123
|
+
logger,
|
|
124
|
+
enableMetrics: true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Rate-limit aware configuration - optimized for APIs with strict rate limits
|
|
129
|
+
*/
|
|
130
|
+
static rateLimitAware(logger) {
|
|
131
|
+
return {
|
|
132
|
+
backoff: {
|
|
133
|
+
type: 'exponential',
|
|
134
|
+
initialDelayMs: 1000,
|
|
135
|
+
maxDelayMs: 300000, // 5 minutes for severe rate limiting
|
|
136
|
+
multiplier: 1.5,
|
|
137
|
+
},
|
|
138
|
+
jitter: {
|
|
139
|
+
type: 'equal',
|
|
140
|
+
factor: 0.05, // Low jitter to respect rate limits
|
|
141
|
+
},
|
|
142
|
+
condition: {
|
|
143
|
+
maxAttempts: 3,
|
|
144
|
+
maxTotalTimeMs: 600000, // 10 minutes total
|
|
145
|
+
retryableStatusCodes: [429],
|
|
146
|
+
retryableErrorTypes: [RateLimitError],
|
|
147
|
+
shouldRetry: (error, attempt, elapsed) => {
|
|
148
|
+
// Custom logic for rate limit errors
|
|
149
|
+
if (error instanceof RateLimitError) {
|
|
150
|
+
return error.canRetry() && attempt < 3;
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
circuitBreaker: {
|
|
156
|
+
enabled: false, // Don't use circuit breaker with rate limits
|
|
157
|
+
failureThreshold: 1,
|
|
158
|
+
recoveryTimeoutMs: 60000,
|
|
159
|
+
halfOpenSuccessThreshold: 1,
|
|
160
|
+
},
|
|
161
|
+
logger,
|
|
162
|
+
enableMetrics: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Network-resilient configuration - optimized for unreliable networks
|
|
167
|
+
*/
|
|
168
|
+
static networkResilient(logger) {
|
|
169
|
+
return {
|
|
170
|
+
backoff: {
|
|
171
|
+
type: 'exponential',
|
|
172
|
+
initialDelayMs: 2000,
|
|
173
|
+
maxDelayMs: 30000,
|
|
174
|
+
multiplier: 2.0,
|
|
175
|
+
},
|
|
176
|
+
jitter: {
|
|
177
|
+
type: 'decorrelated',
|
|
178
|
+
factor: 0.3, // High jitter for network issues
|
|
179
|
+
},
|
|
180
|
+
condition: {
|
|
181
|
+
maxAttempts: 5, // More attempts for network issues
|
|
182
|
+
maxTotalTimeMs: 120000, // 2 minutes
|
|
183
|
+
retryableStatusCodes: [408, 502, 503, 504],
|
|
184
|
+
retryableErrorTypes: [NetworkError],
|
|
185
|
+
shouldRetry: (error, attempt, elapsed) => {
|
|
186
|
+
// Only retry network errors that are explicitly retryable
|
|
187
|
+
if (error instanceof NetworkError) {
|
|
188
|
+
return error.isRetryable() && attempt < 5;
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
circuitBreaker: {
|
|
194
|
+
enabled: true,
|
|
195
|
+
failureThreshold: 7, // Higher threshold for network issues
|
|
196
|
+
recoveryTimeoutMs: 30000,
|
|
197
|
+
halfOpenSuccessThreshold: 2,
|
|
198
|
+
},
|
|
199
|
+
logger,
|
|
200
|
+
enableMetrics: true,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Custom configuration builder for specific use cases
|
|
205
|
+
*/
|
|
206
|
+
static custom() {
|
|
207
|
+
return new RetryConfigBuilder();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Fluent builder for creating custom retry configurations
|
|
212
|
+
*/
|
|
213
|
+
export class RetryConfigBuilder {
|
|
214
|
+
constructor() {
|
|
215
|
+
this.config = {};
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Set backoff strategy
|
|
219
|
+
*/
|
|
220
|
+
withBackoff(strategy) {
|
|
221
|
+
this.config.backoff = strategy;
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Set exponential backoff with defaults
|
|
226
|
+
*/
|
|
227
|
+
withExponentialBackoff(initialDelayMs = 1000, maxDelayMs = 30000, multiplier = 2.0) {
|
|
228
|
+
this.config.backoff = {
|
|
229
|
+
type: 'exponential',
|
|
230
|
+
initialDelayMs,
|
|
231
|
+
maxDelayMs,
|
|
232
|
+
multiplier,
|
|
233
|
+
};
|
|
234
|
+
return this;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Set linear backoff
|
|
238
|
+
*/
|
|
239
|
+
withLinearBackoff(initialDelayMs = 1000, maxDelayMs = 10000) {
|
|
240
|
+
this.config.backoff = {
|
|
241
|
+
type: 'linear',
|
|
242
|
+
initialDelayMs,
|
|
243
|
+
maxDelayMs,
|
|
244
|
+
};
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Set fixed backoff
|
|
249
|
+
*/
|
|
250
|
+
withFixedBackoff(delayMs = 1000) {
|
|
251
|
+
this.config.backoff = {
|
|
252
|
+
type: 'fixed',
|
|
253
|
+
initialDelayMs: delayMs,
|
|
254
|
+
maxDelayMs: delayMs,
|
|
255
|
+
};
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Set custom backoff function
|
|
260
|
+
*/
|
|
261
|
+
withCustomBackoff(initialDelayMs, maxDelayMs, customBackoff) {
|
|
262
|
+
this.config.backoff = {
|
|
263
|
+
type: 'custom',
|
|
264
|
+
initialDelayMs,
|
|
265
|
+
maxDelayMs,
|
|
266
|
+
customBackoff,
|
|
267
|
+
};
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Set jitter configuration
|
|
272
|
+
*/
|
|
273
|
+
withJitter(jitter) {
|
|
274
|
+
this.config.jitter = jitter;
|
|
275
|
+
return this;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Set no jitter
|
|
279
|
+
*/
|
|
280
|
+
withoutJitter() {
|
|
281
|
+
this.config.jitter = { type: 'none' };
|
|
282
|
+
return this;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Set equal jitter
|
|
286
|
+
*/
|
|
287
|
+
withEqualJitter(factor = 0.1) {
|
|
288
|
+
this.config.jitter = { type: 'equal', factor };
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Set full jitter
|
|
293
|
+
*/
|
|
294
|
+
withFullJitter(factor = 0.1) {
|
|
295
|
+
this.config.jitter = { type: 'full', factor };
|
|
296
|
+
return this;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Set decorrelated jitter
|
|
300
|
+
*/
|
|
301
|
+
withDecorrelatedJitter(factor = 0.1) {
|
|
302
|
+
this.config.jitter = { type: 'decorrelated', factor };
|
|
303
|
+
return this;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Set retry conditions
|
|
307
|
+
*/
|
|
308
|
+
withConditions(conditions) {
|
|
309
|
+
this.config.condition = conditions;
|
|
310
|
+
return this;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Set basic retry conditions
|
|
314
|
+
*/
|
|
315
|
+
withBasicConditions(maxAttempts = 3, maxTotalTimeMs = 60000, retryableStatusCodes = [429, 502, 503, 504]) {
|
|
316
|
+
this.config.condition = {
|
|
317
|
+
maxAttempts,
|
|
318
|
+
maxTotalTimeMs,
|
|
319
|
+
retryableStatusCodes,
|
|
320
|
+
retryableErrorTypes: [RateLimitError, NetworkError, GoveeApiError],
|
|
321
|
+
};
|
|
322
|
+
return this;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Set circuit breaker configuration
|
|
326
|
+
*/
|
|
327
|
+
withCircuitBreaker(circuitBreaker) {
|
|
328
|
+
this.config.circuitBreaker = circuitBreaker;
|
|
329
|
+
return this;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Enable circuit breaker with defaults
|
|
333
|
+
*/
|
|
334
|
+
withBasicCircuitBreaker(failureThreshold = 5, recoveryTimeoutMs = 30000, halfOpenSuccessThreshold = 2) {
|
|
335
|
+
this.config.circuitBreaker = {
|
|
336
|
+
enabled: true,
|
|
337
|
+
failureThreshold,
|
|
338
|
+
recoveryTimeoutMs,
|
|
339
|
+
halfOpenSuccessThreshold,
|
|
340
|
+
};
|
|
341
|
+
return this;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Disable circuit breaker
|
|
345
|
+
*/
|
|
346
|
+
withoutCircuitBreaker() {
|
|
347
|
+
this.config.circuitBreaker = {
|
|
348
|
+
enabled: false,
|
|
349
|
+
failureThreshold: 1,
|
|
350
|
+
recoveryTimeoutMs: 1000,
|
|
351
|
+
halfOpenSuccessThreshold: 1,
|
|
352
|
+
};
|
|
353
|
+
return this;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Set logger
|
|
357
|
+
*/
|
|
358
|
+
withLogger(logger) {
|
|
359
|
+
this.config.logger = logger;
|
|
360
|
+
return this;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Enable or disable metrics
|
|
364
|
+
*/
|
|
365
|
+
withMetrics(enabled = true) {
|
|
366
|
+
this.config.enableMetrics = enabled;
|
|
367
|
+
return this;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Build the final configuration
|
|
371
|
+
*/
|
|
372
|
+
build() {
|
|
373
|
+
// Ensure required fields have defaults
|
|
374
|
+
const backoff = this.config.backoff || {
|
|
375
|
+
type: 'exponential',
|
|
376
|
+
initialDelayMs: 1000,
|
|
377
|
+
maxDelayMs: 30000,
|
|
378
|
+
multiplier: 2.0,
|
|
379
|
+
};
|
|
380
|
+
const jitter = this.config.jitter || {
|
|
381
|
+
type: 'equal',
|
|
382
|
+
factor: 0.1,
|
|
383
|
+
};
|
|
384
|
+
const condition = this.config.condition || {
|
|
385
|
+
maxAttempts: 3,
|
|
386
|
+
maxTotalTimeMs: 60000,
|
|
387
|
+
retryableStatusCodes: [429, 502, 503, 504],
|
|
388
|
+
retryableErrorTypes: [RateLimitError, NetworkError, GoveeApiError],
|
|
389
|
+
};
|
|
390
|
+
const circuitBreaker = this.config.circuitBreaker || {
|
|
391
|
+
enabled: true,
|
|
392
|
+
failureThreshold: 5,
|
|
393
|
+
recoveryTimeoutMs: 30000,
|
|
394
|
+
halfOpenSuccessThreshold: 2,
|
|
395
|
+
};
|
|
396
|
+
return {
|
|
397
|
+
backoff,
|
|
398
|
+
jitter,
|
|
399
|
+
condition,
|
|
400
|
+
circuitBreaker,
|
|
401
|
+
logger: this.config.logger,
|
|
402
|
+
enableMetrics: this.config.enableMetrics ?? true,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
//# sourceMappingURL=RetryConfigPresets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RetryConfigPresets.js","sourceRoot":"","sources":["../../../src/infrastructure/retry/RetryConfigPresets.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3E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YACnD,OAAO,EAAE,IAAI;YACb,gBAAgB,EAAE,CAAC;YACnB,iBAAiB,EAAE,KAAK;YACxB,wBAAwB,EAAE,CAAC;SAC5B,CAAC;QAEF,OAAO;YACL,OAAO;YACP,MAAM;YACN,SAAS;YACT,cAAc;YACd,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;YAC1B,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,IAAI;SACjD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Logger } from 'pino';
|
|
2
|
+
import { GoveeApiClientError } from '../../errors';
|
|
3
|
+
/**
|
|
4
|
+
* Backoff strategy configuration for retry policies
|
|
5
|
+
*/
|
|
6
|
+
export interface BackoffStrategy {
|
|
7
|
+
/** Type of backoff algorithm */
|
|
8
|
+
type: 'exponential' | 'linear' | 'fixed' | 'custom';
|
|
9
|
+
/** Initial delay in milliseconds */
|
|
10
|
+
initialDelayMs: number;
|
|
11
|
+
/** Maximum delay between retries in milliseconds */
|
|
12
|
+
maxDelayMs: number;
|
|
13
|
+
/** Multiplier for exponential backoff (default: 2.0) */
|
|
14
|
+
multiplier?: number;
|
|
15
|
+
/** Custom backoff function for 'custom' type */
|
|
16
|
+
customBackoff?: (attempt: number, error: GoveeApiClientError) => number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Jitter configuration to prevent thundering herd problems
|
|
20
|
+
*/
|
|
21
|
+
export interface JitterConfig {
|
|
22
|
+
/** Type of jitter algorithm */
|
|
23
|
+
type: 'none' | 'full' | 'equal' | 'decorrelated';
|
|
24
|
+
/** Jitter factor (0.0 to 1.0) */
|
|
25
|
+
factor?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Retry condition configuration
|
|
29
|
+
*/
|
|
30
|
+
export interface RetryCondition {
|
|
31
|
+
/** Maximum number of retry attempts */
|
|
32
|
+
maxAttempts: number;
|
|
33
|
+
/** Maximum total time to spend retrying in milliseconds */
|
|
34
|
+
maxTotalTimeMs: number;
|
|
35
|
+
/** HTTP status codes that should trigger retries */
|
|
36
|
+
retryableStatusCodes: number[];
|
|
37
|
+
/** Error types that should trigger retries */
|
|
38
|
+
retryableErrorTypes: (new (...args: any[]) => GoveeApiClientError)[];
|
|
39
|
+
/** Custom retry decision function */
|
|
40
|
+
shouldRetry?: (error: GoveeApiClientError, attempt: number, elapsed: number) => boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Circuit breaker configuration for retry policies
|
|
44
|
+
*/
|
|
45
|
+
export interface CircuitBreakerConfig {
|
|
46
|
+
/** Enable circuit breaker functionality */
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
/** Number of consecutive failures to open circuit */
|
|
49
|
+
failureThreshold: number;
|
|
50
|
+
/** Time to wait before attempting to close circuit (ms) */
|
|
51
|
+
recoveryTimeoutMs: number;
|
|
52
|
+
/** Percentage of requests to allow through when half-open */
|
|
53
|
+
halfOpenSuccessThreshold: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Retry metrics for observability
|
|
57
|
+
*/
|
|
58
|
+
export interface RetryMetrics {
|
|
59
|
+
/** Total number of retry attempts */
|
|
60
|
+
totalAttempts: number;
|
|
61
|
+
/** Total number of successful retries */
|
|
62
|
+
successfulRetries: number;
|
|
63
|
+
/** Total number of failed retries */
|
|
64
|
+
failedRetries: number;
|
|
65
|
+
/** Total time spent retrying */
|
|
66
|
+
totalRetryTimeMs: number;
|
|
67
|
+
/** Average retry delay */
|
|
68
|
+
averageRetryDelayMs: number;
|
|
69
|
+
/** Circuit breaker state */
|
|
70
|
+
circuitBreakerState: 'closed' | 'open' | 'half-open';
|
|
71
|
+
/** Last error encountered */
|
|
72
|
+
lastError?: GoveeApiClientError;
|
|
73
|
+
/** Timestamp of last retry attempt */
|
|
74
|
+
lastRetryTimestamp?: Date;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Complete retry policy configuration
|
|
78
|
+
*/
|
|
79
|
+
export interface RetryPolicyConfig {
|
|
80
|
+
/** Backoff strategy configuration */
|
|
81
|
+
backoff: BackoffStrategy;
|
|
82
|
+
/** Jitter configuration */
|
|
83
|
+
jitter: JitterConfig;
|
|
84
|
+
/** Retry condition configuration */
|
|
85
|
+
condition: RetryCondition;
|
|
86
|
+
/** Circuit breaker configuration */
|
|
87
|
+
circuitBreaker?: CircuitBreakerConfig;
|
|
88
|
+
/** Logger instance for retry operations */
|
|
89
|
+
logger?: Logger;
|
|
90
|
+
/** Enable detailed metrics collection */
|
|
91
|
+
enableMetrics?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Enterprise-grade retry policy with exponential backoff, jitter, and circuit breaker
|
|
95
|
+
*/
|
|
96
|
+
export declare class RetryPolicy {
|
|
97
|
+
private readonly config;
|
|
98
|
+
private readonly circuitBreaker?;
|
|
99
|
+
private readonly metrics;
|
|
100
|
+
private readonly logger?;
|
|
101
|
+
constructor(config: RetryPolicyConfig);
|
|
102
|
+
private validateConfig;
|
|
103
|
+
/**
|
|
104
|
+
* Determines if an error should trigger a retry attempt
|
|
105
|
+
*/
|
|
106
|
+
shouldRetry(error: GoveeApiClientError, attempt: number, elapsedTimeMs: number): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Calculates the delay before the next retry attempt
|
|
109
|
+
*/
|
|
110
|
+
calculateDelay(attempt: number, error: GoveeApiClientError): number;
|
|
111
|
+
/**
|
|
112
|
+
* Applies jitter to prevent thundering herd problems
|
|
113
|
+
*/
|
|
114
|
+
private applyJitter;
|
|
115
|
+
/**
|
|
116
|
+
* Records a successful operation
|
|
117
|
+
*/
|
|
118
|
+
recordSuccess(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Records a failed operation
|
|
121
|
+
*/
|
|
122
|
+
recordFailure(error: GoveeApiClientError): void;
|
|
123
|
+
/**
|
|
124
|
+
* Updates retry metrics
|
|
125
|
+
*/
|
|
126
|
+
private updateMetrics;
|
|
127
|
+
/**
|
|
128
|
+
* Gets current retry metrics
|
|
129
|
+
*/
|
|
130
|
+
getMetrics(): Readonly<RetryMetrics>;
|
|
131
|
+
/**
|
|
132
|
+
* Resets retry metrics and circuit breaker
|
|
133
|
+
*/
|
|
134
|
+
reset(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Creates a default retry policy optimized for Govee API
|
|
137
|
+
*/
|
|
138
|
+
static createGoveeOptimized(logger?: Logger): RetryPolicy;
|
|
139
|
+
/**
|
|
140
|
+
* Creates a conservative retry policy for production environments
|
|
141
|
+
*/
|
|
142
|
+
static createConservative(logger?: Logger): RetryPolicy;
|
|
143
|
+
/**
|
|
144
|
+
* Creates an aggressive retry policy for development/testing
|
|
145
|
+
*/
|
|
146
|
+
static createAggressive(logger?: Logger): RetryPolicy;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=RetryPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/retry/RetryPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EACL,mBAAmB,EAKpB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,IAAI,EAAE,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,KAAK,MAAM,CAAC;CACzE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,IAAI,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