@bernierllc/retry-suite 0.1.0
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/LICENSE +5 -0
- package/README.md +654 -0
- package/dist/admin/admin-server.d.ts +30 -0
- package/dist/admin/admin-server.js +348 -0
- package/dist/components/retry-dashboard.d.ts +17 -0
- package/dist/components/retry-dashboard.js +406 -0
- package/dist/config/configuration-manager.d.ts +20 -0
- package/dist/config/configuration-manager.js +309 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +32 -0
- package/dist/integrations/email-integration.d.ts +12 -0
- package/dist/integrations/email-integration.js +215 -0
- package/dist/integrations/integration-manager.d.ts +15 -0
- package/dist/integrations/integration-manager.js +108 -0
- package/dist/integrations/slack-integration.d.ts +10 -0
- package/dist/integrations/slack-integration.js +94 -0
- package/dist/integrations/webhook-integration.d.ts +10 -0
- package/dist/integrations/webhook-integration.js +82 -0
- package/dist/retry-suite.d.ts +34 -0
- package/dist/retry-suite.js +328 -0
- package/dist/types.d.ts +205 -0
- package/dist/types.js +9 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Copyright (c) 2025 Bernier LLC
|
|
2
|
+
|
|
3
|
+
This file is licensed to the client under a limited-use license.
|
|
4
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
5
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
package/README.md
ADDED
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
# @bernierllc/retry-suite
|
|
2
|
+
|
|
3
|
+
Complete retry system with admin interface, monitoring dashboard, and comprehensive retry workflows for production environments.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @bernierllc/retry-suite
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { RetrySuite } from '@bernierllc/retry-suite';
|
|
15
|
+
|
|
16
|
+
const retrySuite = new RetrySuite({
|
|
17
|
+
retryManager: {
|
|
18
|
+
defaultOptions: {
|
|
19
|
+
maxRetries: 5,
|
|
20
|
+
initialDelayMs: 1000,
|
|
21
|
+
backoffFactor: 2
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
retryStorage: {
|
|
25
|
+
type: 'memory',
|
|
26
|
+
options: {}
|
|
27
|
+
},
|
|
28
|
+
retryMonitoring: {
|
|
29
|
+
enabled: true,
|
|
30
|
+
metricsInterval: 60000,
|
|
31
|
+
alertThresholds: {
|
|
32
|
+
failureRate: 0.1,
|
|
33
|
+
averageRetryTime: 5000
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
admin: {
|
|
37
|
+
port: 3000,
|
|
38
|
+
host: 'localhost',
|
|
39
|
+
auth: {
|
|
40
|
+
enabled: false
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
integrations: [],
|
|
44
|
+
logging: {
|
|
45
|
+
level: 'info',
|
|
46
|
+
format: 'json'
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Execute with retry
|
|
51
|
+
const result = await retrySuite.executeWithRetry(
|
|
52
|
+
'api-call',
|
|
53
|
+
async () => {
|
|
54
|
+
const response = await fetch('https://api.example.com/data');
|
|
55
|
+
return response.json();
|
|
56
|
+
},
|
|
57
|
+
{ maxRetries: 3 }
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Start admin interface
|
|
61
|
+
await retrySuite.startAdminServer(3000);
|
|
62
|
+
console.log('Admin interface running at: http://localhost:3000');
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Features
|
|
66
|
+
|
|
67
|
+
### 🔄 Comprehensive Retry System
|
|
68
|
+
- **Exponential backoff** with jitter support
|
|
69
|
+
- **Configurable retry policies** per operation
|
|
70
|
+
- **State persistence** across application restarts
|
|
71
|
+
- **Retry scheduling** for future execution
|
|
72
|
+
|
|
73
|
+
### 📊 Real-time Monitoring
|
|
74
|
+
- **Live metrics dashboard** with WebSocket updates
|
|
75
|
+
- **Performance tracking** and trend analysis
|
|
76
|
+
- **Failure reason analysis** and recommendations
|
|
77
|
+
- **Configurable alerting** with multiple severity levels
|
|
78
|
+
|
|
79
|
+
### 🌐 Admin Web Interface
|
|
80
|
+
- **React-based dashboard** for monitoring and management
|
|
81
|
+
- **Real-time retry status** with pause/resume/cancel controls
|
|
82
|
+
- **Metrics visualization** with historical data
|
|
83
|
+
- **Configuration management** with validation
|
|
84
|
+
|
|
85
|
+
### 🔗 Multi-Platform Integrations
|
|
86
|
+
- **Slack notifications** for alerts and critical failures
|
|
87
|
+
- **Email alerts** with HTML templates
|
|
88
|
+
- **Webhook integrations** for custom workflows
|
|
89
|
+
- **PagerDuty integration** for incident management
|
|
90
|
+
|
|
91
|
+
### 🛡️ Production Ready
|
|
92
|
+
- **Authentication support** for admin interface
|
|
93
|
+
- **Comprehensive logging** with structured output
|
|
94
|
+
- **Error handling** with graceful degradation
|
|
95
|
+
- **Health checks** and monitoring endpoints
|
|
96
|
+
|
|
97
|
+
## Usage Examples
|
|
98
|
+
|
|
99
|
+
### Basic Retry Operations
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { RetrySuite } from '@bernierllc/retry-suite';
|
|
103
|
+
|
|
104
|
+
const retrySuite = new RetrySuite(config);
|
|
105
|
+
|
|
106
|
+
// Simple retry with backoff
|
|
107
|
+
try {
|
|
108
|
+
const result = await retrySuite.retryWithBackoff(async () => {
|
|
109
|
+
// Your async operation here
|
|
110
|
+
return await processData();
|
|
111
|
+
}, {
|
|
112
|
+
maxRetries: 3,
|
|
113
|
+
initialDelayMs: 1000,
|
|
114
|
+
backoffFactor: 2
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
console.log('Operation succeeded:', result);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('Operation failed after retries:', error);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Scheduled retry for future execution
|
|
123
|
+
const scheduleResult = await retrySuite.scheduleRetry(
|
|
124
|
+
'batch-job',
|
|
125
|
+
async () => await runBatchProcess(),
|
|
126
|
+
new Date(Date.now() + 60000) // Execute in 1 minute
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
if (scheduleResult.success) {
|
|
130
|
+
console.log('Job scheduled with ID:', scheduleResult.scheduleId);
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Retry Management
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// Get retry status
|
|
138
|
+
const status = await retrySuite.getRetryStatus('operation-id');
|
|
139
|
+
console.log('Retry status:', status);
|
|
140
|
+
|
|
141
|
+
// Cancel a running retry
|
|
142
|
+
const cancelResult = await retrySuite.cancelRetry('operation-id');
|
|
143
|
+
if (cancelResult.success) {
|
|
144
|
+
console.log('Retry cancelled successfully');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Pause and resume retries
|
|
148
|
+
await retrySuite.pauseRetry('operation-id');
|
|
149
|
+
await retrySuite.resumeRetry('operation-id');
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Metrics and Reporting
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
// Get current metrics
|
|
156
|
+
const metrics = await retrySuite.getMetrics();
|
|
157
|
+
console.log('Success rate:', metrics.retrySuccessRate);
|
|
158
|
+
console.log('Average retry time:', metrics.averageRetryTime);
|
|
159
|
+
|
|
160
|
+
// Get performance report
|
|
161
|
+
const report = await retrySuite.getPerformanceReport({
|
|
162
|
+
startDate: new Date('2024-01-01'),
|
|
163
|
+
endDate: new Date('2024-01-31')
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
console.log('Monthly summary:', report.summary);
|
|
167
|
+
console.log('Recommendations:', report.recommendations);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Integration Setup
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
const retrySuite = new RetrySuite({
|
|
174
|
+
// ... other config
|
|
175
|
+
integrations: [
|
|
176
|
+
// Slack integration
|
|
177
|
+
{
|
|
178
|
+
type: 'slack',
|
|
179
|
+
config: {
|
|
180
|
+
token: process.env.SLACK_BOT_TOKEN,
|
|
181
|
+
channel: '#alerts',
|
|
182
|
+
criticalChannel: '#critical-alerts'
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
// Email integration
|
|
187
|
+
{
|
|
188
|
+
type: 'email',
|
|
189
|
+
config: {
|
|
190
|
+
provider: 'sendgrid',
|
|
191
|
+
apiKey: process.env.SENDGRID_API_KEY,
|
|
192
|
+
from: 'alerts@company.com',
|
|
193
|
+
to: ['admin@company.com', 'devops@company.com']
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
// Webhook integration
|
|
198
|
+
{
|
|
199
|
+
type: 'webhook',
|
|
200
|
+
config: {
|
|
201
|
+
url: 'https://api.company.com/webhooks/retry-alerts',
|
|
202
|
+
headers: {
|
|
203
|
+
'Authorization': `Bearer ${process.env.WEBHOOK_TOKEN}`
|
|
204
|
+
},
|
|
205
|
+
timeout: 10000
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### React Dashboard Integration
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import React from 'react';
|
|
216
|
+
import { RetryDashboard } from '@bernierllc/retry-suite';
|
|
217
|
+
|
|
218
|
+
export const MonitoringPage: React.FC = () => {
|
|
219
|
+
return (
|
|
220
|
+
<div>
|
|
221
|
+
<h1>System Monitoring</h1>
|
|
222
|
+
<RetryDashboard apiBaseUrl="/api/retry-suite" />
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Custom Retry Policies
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// High-frequency, low-latency operations
|
|
232
|
+
const quickRetryOptions = {
|
|
233
|
+
maxRetries: 3,
|
|
234
|
+
initialDelayMs: 100,
|
|
235
|
+
backoffFactor: 1.5,
|
|
236
|
+
maxDelayMs: 1000,
|
|
237
|
+
jitter: false
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// Heavy operations with longer delays
|
|
241
|
+
const heavyRetryOptions = {
|
|
242
|
+
maxRetries: 5,
|
|
243
|
+
initialDelayMs: 5000,
|
|
244
|
+
backoffFactor: 2,
|
|
245
|
+
maxDelayMs: 60000,
|
|
246
|
+
jitter: true
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
await retrySuite.executeWithRetry('quick-api-call', quickOperation, quickRetryOptions);
|
|
250
|
+
await retrySuite.executeWithRetry('heavy-batch-job', heavyOperation, heavyRetryOptions);
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Configuration
|
|
254
|
+
|
|
255
|
+
### Complete Configuration Example
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import { RetrySuiteConfig } from '@bernierllc/retry-suite';
|
|
259
|
+
|
|
260
|
+
const config: RetrySuiteConfig = {
|
|
261
|
+
// Retry manager configuration
|
|
262
|
+
retryManager: {
|
|
263
|
+
defaultOptions: {
|
|
264
|
+
maxRetries: 5,
|
|
265
|
+
initialDelayMs: 1000,
|
|
266
|
+
backoffFactor: 2,
|
|
267
|
+
maxDelayMs: 30000,
|
|
268
|
+
jitter: true
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
// Storage configuration
|
|
273
|
+
retryStorage: {
|
|
274
|
+
type: 'redis', // 'memory', 'redis', or 'file'
|
|
275
|
+
options: {
|
|
276
|
+
url: process.env.REDIS_URL,
|
|
277
|
+
keyPrefix: 'retry-suite:',
|
|
278
|
+
ttl: 3600 // 1 hour TTL for retry state
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
|
|
282
|
+
// Monitoring configuration
|
|
283
|
+
retryMonitoring: {
|
|
284
|
+
enabled: true,
|
|
285
|
+
metricsInterval: 60000, // Collect metrics every minute
|
|
286
|
+
alertThresholds: {
|
|
287
|
+
failureRate: 0.1, // Alert if >10% failure rate
|
|
288
|
+
averageRetryTime: 5000 // Alert if average >5 seconds
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
// Admin interface configuration
|
|
293
|
+
admin: {
|
|
294
|
+
port: 3000,
|
|
295
|
+
host: '0.0.0.0',
|
|
296
|
+
auth: {
|
|
297
|
+
enabled: true,
|
|
298
|
+
username: 'admin',
|
|
299
|
+
password: process.env.ADMIN_PASSWORD
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
// Integration configurations
|
|
304
|
+
integrations: [
|
|
305
|
+
{
|
|
306
|
+
type: 'slack',
|
|
307
|
+
config: {
|
|
308
|
+
token: process.env.SLACK_BOT_TOKEN,
|
|
309
|
+
channel: '#retry-alerts',
|
|
310
|
+
criticalChannel: '#critical'
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
],
|
|
314
|
+
|
|
315
|
+
// Logging configuration
|
|
316
|
+
logging: {
|
|
317
|
+
level: 'info', // 'debug', 'info', 'warn', 'error'
|
|
318
|
+
format: 'json' // 'json' or 'text'
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Storage Options
|
|
324
|
+
|
|
325
|
+
#### Memory Storage (Development)
|
|
326
|
+
```typescript
|
|
327
|
+
retryStorage: {
|
|
328
|
+
type: 'memory',
|
|
329
|
+
options: {}
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### Redis Storage (Production)
|
|
334
|
+
```typescript
|
|
335
|
+
retryStorage: {
|
|
336
|
+
type: 'redis',
|
|
337
|
+
options: {
|
|
338
|
+
url: 'redis://localhost:6379',
|
|
339
|
+
keyPrefix: 'retry-suite:',
|
|
340
|
+
ttl: 3600,
|
|
341
|
+
maxRetries: 3,
|
|
342
|
+
retryDelayOnFailover: 100
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
#### File Storage (Lightweight Persistence)
|
|
348
|
+
```typescript
|
|
349
|
+
retryStorage: {
|
|
350
|
+
type: 'file',
|
|
351
|
+
options: {
|
|
352
|
+
path: './retry-state.json',
|
|
353
|
+
syncInterval: 5000,
|
|
354
|
+
maxFileSize: 10485760 // 10MB
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## API Reference
|
|
360
|
+
|
|
361
|
+
### RetrySuite Class
|
|
362
|
+
|
|
363
|
+
#### Constructor
|
|
364
|
+
```typescript
|
|
365
|
+
new RetrySuite(config: RetrySuiteConfig)
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
#### Core Methods
|
|
369
|
+
|
|
370
|
+
##### `executeWithRetry<T>(id: string, fn: () => Promise<T>, options?: RetryOptions): Promise<RetryResult<T>>`
|
|
371
|
+
Execute a function with retry logic and comprehensive tracking.
|
|
372
|
+
|
|
373
|
+
##### `retryWithBackoff<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>`
|
|
374
|
+
Execute a function with exponential backoff, throwing on final failure.
|
|
375
|
+
|
|
376
|
+
##### `scheduleRetry(id: string, fn: () => Promise<any>, scheduleTime: Date): Promise<ScheduleResult>`
|
|
377
|
+
Schedule a retry operation for future execution.
|
|
378
|
+
|
|
379
|
+
#### Management Methods
|
|
380
|
+
|
|
381
|
+
##### `getRetryStatus(id: string): Promise<RetryStatus | null>`
|
|
382
|
+
Get the current status of a retry operation.
|
|
383
|
+
|
|
384
|
+
##### `cancelRetry(id: string): Promise<CancelResult>`
|
|
385
|
+
Cancel a running retry operation.
|
|
386
|
+
|
|
387
|
+
##### `pauseRetry(id: string): Promise<PauseResult>`
|
|
388
|
+
Pause a running retry operation.
|
|
389
|
+
|
|
390
|
+
##### `resumeRetry(id: string): Promise<ResumeResult>`
|
|
391
|
+
Resume a paused retry operation.
|
|
392
|
+
|
|
393
|
+
#### Monitoring Methods
|
|
394
|
+
|
|
395
|
+
##### `getMetrics(options?: MetricsOptions): Promise<RetryMetrics>`
|
|
396
|
+
Get current system metrics and statistics.
|
|
397
|
+
|
|
398
|
+
##### `getAlerts(options?: AlertOptions): Promise<Alert[]>`
|
|
399
|
+
Get system alerts with optional filtering.
|
|
400
|
+
|
|
401
|
+
##### `getPerformanceReport(options?: ReportOptions): Promise<PerformanceReport>`
|
|
402
|
+
Generate comprehensive performance report with recommendations.
|
|
403
|
+
|
|
404
|
+
#### Configuration Methods
|
|
405
|
+
|
|
406
|
+
##### `updateConfiguration(config: Partial<RetrySuiteConfig>): Promise<ConfigResult>`
|
|
407
|
+
Update system configuration with validation.
|
|
408
|
+
|
|
409
|
+
##### `getConfiguration(): RetrySuiteConfig`
|
|
410
|
+
Get current system configuration.
|
|
411
|
+
|
|
412
|
+
##### `validateConfiguration(config: RetrySuiteConfig): ValidationResult`
|
|
413
|
+
Validate a configuration object.
|
|
414
|
+
|
|
415
|
+
#### Admin Server Methods
|
|
416
|
+
|
|
417
|
+
##### `startAdminServer(port?: number): Promise<void>`
|
|
418
|
+
Start the admin web interface server.
|
|
419
|
+
|
|
420
|
+
##### `stopAdminServer(): Promise<void>`
|
|
421
|
+
Stop the admin web interface server.
|
|
422
|
+
|
|
423
|
+
##### `getAdminUrl(): string`
|
|
424
|
+
Get the URL of the admin interface.
|
|
425
|
+
|
|
426
|
+
## Integration Guides
|
|
427
|
+
|
|
428
|
+
### Slack Integration
|
|
429
|
+
|
|
430
|
+
1. Create a Slack Bot in your workspace
|
|
431
|
+
2. Add the bot to desired channels
|
|
432
|
+
3. Configure the integration:
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
{
|
|
436
|
+
type: 'slack',
|
|
437
|
+
config: {
|
|
438
|
+
token: 'xoxb-your-bot-token',
|
|
439
|
+
channel: '#alerts',
|
|
440
|
+
criticalChannel: '#critical-alerts'
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### Email Integration
|
|
446
|
+
|
|
447
|
+
Supports multiple email providers:
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
// SendGrid
|
|
451
|
+
{
|
|
452
|
+
type: 'email',
|
|
453
|
+
config: {
|
|
454
|
+
provider: 'sendgrid',
|
|
455
|
+
apiKey: process.env.SENDGRID_API_KEY,
|
|
456
|
+
from: 'alerts@company.com',
|
|
457
|
+
to: ['admin@company.com']
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// Amazon SES
|
|
462
|
+
{
|
|
463
|
+
type: 'email',
|
|
464
|
+
config: {
|
|
465
|
+
provider: 'ses',
|
|
466
|
+
apiKey: process.env.AWS_ACCESS_KEY_ID,
|
|
467
|
+
apiSecret: process.env.AWS_SECRET_ACCESS_KEY,
|
|
468
|
+
region: 'us-east-1',
|
|
469
|
+
from: 'alerts@company.com',
|
|
470
|
+
to: ['admin@company.com']
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### Webhook Integration
|
|
476
|
+
|
|
477
|
+
```typescript
|
|
478
|
+
{
|
|
479
|
+
type: 'webhook',
|
|
480
|
+
config: {
|
|
481
|
+
url: 'https://api.company.com/webhooks/retry-alerts',
|
|
482
|
+
headers: {
|
|
483
|
+
'Authorization': 'Bearer your-webhook-token',
|
|
484
|
+
'Content-Type': 'application/json'
|
|
485
|
+
},
|
|
486
|
+
timeout: 10000
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
## Monitoring & Alerting
|
|
492
|
+
|
|
493
|
+
### Metrics Tracked
|
|
494
|
+
- **Total retries**: Number of retry operations
|
|
495
|
+
- **Success rate**: Percentage of successful operations
|
|
496
|
+
- **Average retry time**: Mean time to completion
|
|
497
|
+
- **Active retries**: Currently running operations
|
|
498
|
+
- **Failure reasons**: Analysis of common failure patterns
|
|
499
|
+
- **Performance trends**: Historical performance data
|
|
500
|
+
|
|
501
|
+
### Alert Conditions
|
|
502
|
+
- **High failure rate**: Configurable threshold
|
|
503
|
+
- **Slow retry times**: Performance degradation detection
|
|
504
|
+
- **Critical failures**: System-level errors
|
|
505
|
+
- **Resource exhaustion**: Storage or memory limits
|
|
506
|
+
|
|
507
|
+
### Performance Recommendations
|
|
508
|
+
The system provides automatic recommendations based on metrics:
|
|
509
|
+
- Retry policy adjustments
|
|
510
|
+
- Resource allocation suggestions
|
|
511
|
+
- Integration health checks
|
|
512
|
+
- Configuration optimizations
|
|
513
|
+
|
|
514
|
+
## Production Deployment
|
|
515
|
+
|
|
516
|
+
### Environment Variables
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
# Required
|
|
520
|
+
REDIS_URL=redis://localhost:6379
|
|
521
|
+
ADMIN_PASSWORD=your-secure-password
|
|
522
|
+
|
|
523
|
+
# Optional integrations
|
|
524
|
+
SLACK_BOT_TOKEN=xoxb-your-token
|
|
525
|
+
SENDGRID_API_KEY=your-api-key
|
|
526
|
+
WEBHOOK_TOKEN=your-webhook-token
|
|
527
|
+
|
|
528
|
+
# Optional settings
|
|
529
|
+
NODE_ENV=production
|
|
530
|
+
LOG_LEVEL=info
|
|
531
|
+
METRICS_INTERVAL=60000
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### Docker Deployment
|
|
535
|
+
|
|
536
|
+
```dockerfile
|
|
537
|
+
FROM node:18-alpine
|
|
538
|
+
|
|
539
|
+
WORKDIR /app
|
|
540
|
+
COPY package*.json ./
|
|
541
|
+
RUN npm ci --only=production
|
|
542
|
+
|
|
543
|
+
COPY . .
|
|
544
|
+
RUN npm run build
|
|
545
|
+
|
|
546
|
+
EXPOSE 3000
|
|
547
|
+
CMD ["node", "dist/index.js"]
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### Health Checks
|
|
551
|
+
|
|
552
|
+
```typescript
|
|
553
|
+
// Health check endpoint
|
|
554
|
+
GET /health
|
|
555
|
+
|
|
556
|
+
// Response
|
|
557
|
+
{
|
|
558
|
+
"status": "healthy",
|
|
559
|
+
"timestamp": "2024-01-01T10:00:00Z",
|
|
560
|
+
"version": "0.1.0",
|
|
561
|
+
"metrics": {
|
|
562
|
+
"activeRetries": 5,
|
|
563
|
+
"uptime": 3600
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### Monitoring Integration
|
|
569
|
+
|
|
570
|
+
```typescript
|
|
571
|
+
// Prometheus metrics endpoint
|
|
572
|
+
GET /metrics
|
|
573
|
+
|
|
574
|
+
// Custom health check
|
|
575
|
+
async function healthCheck() {
|
|
576
|
+
const metrics = await retrySuite.getMetrics();
|
|
577
|
+
return {
|
|
578
|
+
healthy: metrics.retrySuccessRate > 0.8,
|
|
579
|
+
metrics
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
## Troubleshooting
|
|
585
|
+
|
|
586
|
+
### Common Issues
|
|
587
|
+
|
|
588
|
+
#### High Memory Usage
|
|
589
|
+
- Use Redis storage instead of memory storage
|
|
590
|
+
- Implement retry state cleanup
|
|
591
|
+
- Monitor storage metrics
|
|
592
|
+
|
|
593
|
+
#### Slow Performance
|
|
594
|
+
- Optimize retry policies
|
|
595
|
+
- Check network connectivity
|
|
596
|
+
- Review failure patterns
|
|
597
|
+
|
|
598
|
+
#### Missing Alerts
|
|
599
|
+
- Verify integration configurations
|
|
600
|
+
- Check alert thresholds
|
|
601
|
+
- Test integration connectivity
|
|
602
|
+
|
|
603
|
+
### Debug Mode
|
|
604
|
+
|
|
605
|
+
```typescript
|
|
606
|
+
const config = {
|
|
607
|
+
// ... other config
|
|
608
|
+
logging: {
|
|
609
|
+
level: 'debug',
|
|
610
|
+
format: 'text'
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
### Monitoring Commands
|
|
616
|
+
|
|
617
|
+
```bash
|
|
618
|
+
# Check retry suite status
|
|
619
|
+
curl http://localhost:3000/health
|
|
620
|
+
|
|
621
|
+
# View current metrics
|
|
622
|
+
curl http://localhost:3000/api/metrics
|
|
623
|
+
|
|
624
|
+
# List active retries
|
|
625
|
+
curl http://localhost:3000/api/retries
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
## Dependencies
|
|
629
|
+
|
|
630
|
+
### Internal Dependencies
|
|
631
|
+
- `@bernierllc/retry-manager`: Core retry orchestration
|
|
632
|
+
- `@bernierllc/retry-storage`: Retry state management (when available)
|
|
633
|
+
- `@bernierllc/retry-monitoring`: Metrics and alerting (when available)
|
|
634
|
+
|
|
635
|
+
### External Dependencies
|
|
636
|
+
- `express`: Web server for admin interface
|
|
637
|
+
- `react`: Frontend framework for dashboard
|
|
638
|
+
- `cors`: Cross-origin resource sharing
|
|
639
|
+
- `helmet`: Security middleware
|
|
640
|
+
- `compression`: Response compression
|
|
641
|
+
- `ws`: WebSocket support
|
|
642
|
+
|
|
643
|
+
### Peer Dependencies
|
|
644
|
+
- `react`: ^18.0.0 (for React components)
|
|
645
|
+
|
|
646
|
+
## License
|
|
647
|
+
|
|
648
|
+
Copyright (c) 2025 Bernier LLC. All rights reserved.
|
|
649
|
+
|
|
650
|
+
This package is licensed under a limited-use license. See the LICENSE file for details.
|
|
651
|
+
|
|
652
|
+
---
|
|
653
|
+
|
|
654
|
+
For more information and examples, visit the [GitHub repository](https://github.com/BernierLLC/tools/tree/main/packages/suite/retry-suite).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AdminConfig } from '../types';
|
|
2
|
+
export declare class AdminServer {
|
|
3
|
+
private app;
|
|
4
|
+
private server;
|
|
5
|
+
private wss;
|
|
6
|
+
private config;
|
|
7
|
+
private retrySuite;
|
|
8
|
+
private connectedClients;
|
|
9
|
+
constructor(config: AdminConfig, retrySuite: any);
|
|
10
|
+
private setupMiddleware;
|
|
11
|
+
private setupRoutes;
|
|
12
|
+
private authMiddleware;
|
|
13
|
+
private handleGetMetrics;
|
|
14
|
+
private handleGetRetries;
|
|
15
|
+
private handleGetRetry;
|
|
16
|
+
private handleCancelRetry;
|
|
17
|
+
private handlePauseRetry;
|
|
18
|
+
private handleResumeRetry;
|
|
19
|
+
private handleGetAlerts;
|
|
20
|
+
private handleGetPerformanceReport;
|
|
21
|
+
private handleGetConfig;
|
|
22
|
+
private handleUpdateConfig;
|
|
23
|
+
private setupWebSocket;
|
|
24
|
+
private setupRealTimeUpdates;
|
|
25
|
+
private sendRealTimeUpdate;
|
|
26
|
+
private broadcastToClients;
|
|
27
|
+
start(port: number): Promise<void>;
|
|
28
|
+
stop(): Promise<void>;
|
|
29
|
+
getUrl(): string;
|
|
30
|
+
}
|