@zintrust/workers 0.1.27

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.
Files changed (178) hide show
  1. package/README.md +861 -0
  2. package/dist/AnomalyDetection.d.ts +102 -0
  3. package/dist/AnomalyDetection.js +321 -0
  4. package/dist/AutoScaler.d.ts +127 -0
  5. package/dist/AutoScaler.js +425 -0
  6. package/dist/BroadcastWorker.d.ts +21 -0
  7. package/dist/BroadcastWorker.js +24 -0
  8. package/dist/CanaryController.d.ts +103 -0
  9. package/dist/CanaryController.js +380 -0
  10. package/dist/ChaosEngineering.d.ts +79 -0
  11. package/dist/ChaosEngineering.js +216 -0
  12. package/dist/CircuitBreaker.d.ts +106 -0
  13. package/dist/CircuitBreaker.js +374 -0
  14. package/dist/ClusterLock.d.ts +90 -0
  15. package/dist/ClusterLock.js +385 -0
  16. package/dist/ComplianceManager.d.ts +177 -0
  17. package/dist/ComplianceManager.js +556 -0
  18. package/dist/DatacenterOrchestrator.d.ts +133 -0
  19. package/dist/DatacenterOrchestrator.js +404 -0
  20. package/dist/DeadLetterQueue.d.ts +122 -0
  21. package/dist/DeadLetterQueue.js +539 -0
  22. package/dist/HealthMonitor.d.ts +42 -0
  23. package/dist/HealthMonitor.js +301 -0
  24. package/dist/MultiQueueWorker.d.ts +89 -0
  25. package/dist/MultiQueueWorker.js +277 -0
  26. package/dist/NotificationWorker.d.ts +21 -0
  27. package/dist/NotificationWorker.js +23 -0
  28. package/dist/Observability.d.ts +153 -0
  29. package/dist/Observability.js +530 -0
  30. package/dist/PluginManager.d.ts +123 -0
  31. package/dist/PluginManager.js +392 -0
  32. package/dist/PriorityQueue.d.ts +117 -0
  33. package/dist/PriorityQueue.js +244 -0
  34. package/dist/ResourceMonitor.d.ts +164 -0
  35. package/dist/ResourceMonitor.js +605 -0
  36. package/dist/SLAMonitor.d.ts +110 -0
  37. package/dist/SLAMonitor.js +274 -0
  38. package/dist/WorkerFactory.d.ts +193 -0
  39. package/dist/WorkerFactory.js +1507 -0
  40. package/dist/WorkerInit.d.ts +85 -0
  41. package/dist/WorkerInit.js +223 -0
  42. package/dist/WorkerMetrics.d.ts +114 -0
  43. package/dist/WorkerMetrics.js +509 -0
  44. package/dist/WorkerRegistry.d.ts +145 -0
  45. package/dist/WorkerRegistry.js +319 -0
  46. package/dist/WorkerShutdown.d.ts +61 -0
  47. package/dist/WorkerShutdown.js +159 -0
  48. package/dist/WorkerVersioning.d.ts +107 -0
  49. package/dist/WorkerVersioning.js +300 -0
  50. package/dist/build-manifest.json +462 -0
  51. package/dist/config/workerConfig.d.ts +3 -0
  52. package/dist/config/workerConfig.js +19 -0
  53. package/dist/createQueueWorker.d.ts +23 -0
  54. package/dist/createQueueWorker.js +113 -0
  55. package/dist/dashboard/index.d.ts +1 -0
  56. package/dist/dashboard/index.js +1 -0
  57. package/dist/dashboard/types.d.ts +117 -0
  58. package/dist/dashboard/types.js +1 -0
  59. package/dist/dashboard/workers-api.d.ts +4 -0
  60. package/dist/dashboard/workers-api.js +638 -0
  61. package/dist/dashboard/workers-dashboard-ui.d.ts +3 -0
  62. package/dist/dashboard/workers-dashboard-ui.js +1026 -0
  63. package/dist/dashboard/workers-dashboard.d.ts +4 -0
  64. package/dist/dashboard/workers-dashboard.js +904 -0
  65. package/dist/helper/index.d.ts +5 -0
  66. package/dist/helper/index.js +10 -0
  67. package/dist/http/WorkerApiController.d.ts +38 -0
  68. package/dist/http/WorkerApiController.js +312 -0
  69. package/dist/http/WorkerController.d.ts +374 -0
  70. package/dist/http/WorkerController.js +1351 -0
  71. package/dist/http/middleware/CustomValidation.d.ts +92 -0
  72. package/dist/http/middleware/CustomValidation.js +270 -0
  73. package/dist/http/middleware/DatacenterValidator.d.ts +3 -0
  74. package/dist/http/middleware/DatacenterValidator.js +94 -0
  75. package/dist/http/middleware/EditWorkerValidation.d.ts +7 -0
  76. package/dist/http/middleware/EditWorkerValidation.js +55 -0
  77. package/dist/http/middleware/FeaturesValidator.d.ts +3 -0
  78. package/dist/http/middleware/FeaturesValidator.js +60 -0
  79. package/dist/http/middleware/InfrastructureValidator.d.ts +31 -0
  80. package/dist/http/middleware/InfrastructureValidator.js +226 -0
  81. package/dist/http/middleware/OptionsValidator.d.ts +3 -0
  82. package/dist/http/middleware/OptionsValidator.js +112 -0
  83. package/dist/http/middleware/PayloadSanitizer.d.ts +7 -0
  84. package/dist/http/middleware/PayloadSanitizer.js +42 -0
  85. package/dist/http/middleware/ProcessorPathSanitizer.d.ts +3 -0
  86. package/dist/http/middleware/ProcessorPathSanitizer.js +74 -0
  87. package/dist/http/middleware/QueueNameSanitizer.d.ts +3 -0
  88. package/dist/http/middleware/QueueNameSanitizer.js +45 -0
  89. package/dist/http/middleware/ValidateDriver.d.ts +7 -0
  90. package/dist/http/middleware/ValidateDriver.js +20 -0
  91. package/dist/http/middleware/VersionSanitizer.d.ts +3 -0
  92. package/dist/http/middleware/VersionSanitizer.js +25 -0
  93. package/dist/http/middleware/WorkerNameSanitizer.d.ts +3 -0
  94. package/dist/http/middleware/WorkerNameSanitizer.js +46 -0
  95. package/dist/http/middleware/WorkerValidationChain.d.ts +27 -0
  96. package/dist/http/middleware/WorkerValidationChain.js +185 -0
  97. package/dist/index.d.ts +46 -0
  98. package/dist/index.js +48 -0
  99. package/dist/routes/workers.d.ts +12 -0
  100. package/dist/routes/workers.js +81 -0
  101. package/dist/storage/WorkerStore.d.ts +45 -0
  102. package/dist/storage/WorkerStore.js +195 -0
  103. package/dist/type.d.ts +76 -0
  104. package/dist/type.js +1 -0
  105. package/dist/ui/router/ui.d.ts +3 -0
  106. package/dist/ui/router/ui.js +83 -0
  107. package/dist/ui/types/worker-ui.d.ts +229 -0
  108. package/dist/ui/types/worker-ui.js +5 -0
  109. package/package.json +53 -0
  110. package/src/AnomalyDetection.ts +434 -0
  111. package/src/AutoScaler.ts +654 -0
  112. package/src/BroadcastWorker.ts +34 -0
  113. package/src/CanaryController.ts +531 -0
  114. package/src/ChaosEngineering.ts +301 -0
  115. package/src/CircuitBreaker.ts +495 -0
  116. package/src/ClusterLock.ts +499 -0
  117. package/src/ComplianceManager.ts +815 -0
  118. package/src/DatacenterOrchestrator.ts +561 -0
  119. package/src/DeadLetterQueue.ts +733 -0
  120. package/src/HealthMonitor.ts +390 -0
  121. package/src/MultiQueueWorker.ts +431 -0
  122. package/src/NotificationWorker.ts +33 -0
  123. package/src/Observability.ts +696 -0
  124. package/src/PluginManager.ts +551 -0
  125. package/src/PriorityQueue.ts +351 -0
  126. package/src/ResourceMonitor.ts +769 -0
  127. package/src/SLAMonitor.ts +408 -0
  128. package/src/WorkerFactory.ts +2108 -0
  129. package/src/WorkerInit.ts +313 -0
  130. package/src/WorkerMetrics.ts +709 -0
  131. package/src/WorkerRegistry.ts +443 -0
  132. package/src/WorkerShutdown.ts +210 -0
  133. package/src/WorkerVersioning.ts +422 -0
  134. package/src/config/workerConfig.ts +25 -0
  135. package/src/createQueueWorker.ts +174 -0
  136. package/src/dashboard/index.ts +6 -0
  137. package/src/dashboard/types.ts +141 -0
  138. package/src/dashboard/workers-api.ts +785 -0
  139. package/src/dashboard/zintrust.svg +30 -0
  140. package/src/helper/index.ts +11 -0
  141. package/src/http/WorkerApiController.ts +369 -0
  142. package/src/http/WorkerController.ts +1512 -0
  143. package/src/http/middleware/CustomValidation.ts +360 -0
  144. package/src/http/middleware/DatacenterValidator.ts +124 -0
  145. package/src/http/middleware/EditWorkerValidation.ts +74 -0
  146. package/src/http/middleware/FeaturesValidator.ts +82 -0
  147. package/src/http/middleware/InfrastructureValidator.ts +295 -0
  148. package/src/http/middleware/OptionsValidator.ts +144 -0
  149. package/src/http/middleware/PayloadSanitizer.ts +52 -0
  150. package/src/http/middleware/ProcessorPathSanitizer.ts +86 -0
  151. package/src/http/middleware/QueueNameSanitizer.ts +55 -0
  152. package/src/http/middleware/ValidateDriver.ts +29 -0
  153. package/src/http/middleware/VersionSanitizer.ts +30 -0
  154. package/src/http/middleware/WorkerNameSanitizer.ts +56 -0
  155. package/src/http/middleware/WorkerValidationChain.ts +230 -0
  156. package/src/index.ts +98 -0
  157. package/src/routes/workers.ts +154 -0
  158. package/src/storage/WorkerStore.ts +240 -0
  159. package/src/type.ts +89 -0
  160. package/src/types/queue-monitor.d.ts +38 -0
  161. package/src/types/queue-redis.d.ts +38 -0
  162. package/src/ui/README.md +13 -0
  163. package/src/ui/components/JsonEditor.js +670 -0
  164. package/src/ui/components/JsonViewer.js +387 -0
  165. package/src/ui/components/WorkerCard.js +178 -0
  166. package/src/ui/components/WorkerExpandPanel.js +257 -0
  167. package/src/ui/components/fetcher.js +42 -0
  168. package/src/ui/components/sla-scorecard.js +32 -0
  169. package/src/ui/components/styles.css +30 -0
  170. package/src/ui/components/table-expander.js +34 -0
  171. package/src/ui/integration/worker-ui-integration.js +565 -0
  172. package/src/ui/router/ui.ts +99 -0
  173. package/src/ui/services/workerApi.js +240 -0
  174. package/src/ui/types/worker-ui.ts +283 -0
  175. package/src/ui/utils/jsonValidator.js +444 -0
  176. package/src/ui/workers/index.html +202 -0
  177. package/src/ui/workers/main.js +1781 -0
  178. package/src/ui/workers/styles.css +1350 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Worker Management System Initializer
3
+ *
4
+ * Handles initialization and lifecycle management of the worker management system.
5
+ * - Registers shutdown handlers
6
+ * - Initializes monitoring and resource management
7
+ * - Sets up auto-scaling and health checks
8
+ * - Ensures graceful startup and shutdown
9
+ */
10
+ export interface IWorkerInitOptions {
11
+ /**
12
+ * Whether to start resource monitoring on initialization
13
+ * @default true
14
+ */
15
+ enableResourceMonitoring?: boolean;
16
+ /**
17
+ * Whether to start health monitoring on initialization
18
+ * @default true
19
+ */
20
+ enableHealthMonitoring?: boolean;
21
+ /**
22
+ * Whether to start auto-scaling on initialization
23
+ * @default false - must be explicitly enabled
24
+ */
25
+ enableAutoScaling?: boolean;
26
+ /**
27
+ * Whether to register graceful shutdown handlers
28
+ * @default true
29
+ */
30
+ registerShutdownHandlers?: boolean;
31
+ /**
32
+ * Resource monitoring interval in milliseconds
33
+ * @default 60000 (1 minute)
34
+ */
35
+ resourceMonitoringInterval?: number;
36
+ }
37
+ interface IInitState {
38
+ initialized: boolean;
39
+ initializedAt: Date | null;
40
+ resourceMonitoring: boolean;
41
+ healthMonitoring: boolean;
42
+ autoScaling: boolean;
43
+ shutdownHandlersRegistered: boolean;
44
+ }
45
+ /**
46
+ * Initialize the worker management system
47
+ */
48
+ declare function initialize(options?: IWorkerInitOptions): Promise<void>;
49
+ declare function autoStartPersistedWorkers(): Promise<void>;
50
+ /**
51
+ * Check if worker management system is initialized
52
+ */
53
+ declare function isInitialized(): boolean;
54
+ /**
55
+ * Get initialization state
56
+ */
57
+ declare function getInitState(): Readonly<IInitState>;
58
+ /**
59
+ * Graceful shutdown of worker management system
60
+ * (convenience method that delegates to WorkerShutdown)
61
+ */
62
+ declare function shutdown(): Promise<void>;
63
+ export declare const WorkerInit: Readonly<{
64
+ /**
65
+ * Initialize the worker management system
66
+ */
67
+ initialize: typeof initialize;
68
+ /**
69
+ * Check if worker management system is initialized
70
+ */
71
+ isInitialized: typeof isInitialized;
72
+ /**
73
+ * Get initialization state
74
+ */
75
+ getInitState: typeof getInitState;
76
+ /**
77
+ * Graceful shutdown of worker management system
78
+ */
79
+ shutdown: typeof shutdown;
80
+ /**
81
+ * Start persisted workers after boot completes
82
+ */
83
+ autoStartPersistedWorkers: typeof autoStartPersistedWorkers;
84
+ }>;
85
+ export {};
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Worker Management System Initializer
3
+ *
4
+ * Handles initialization and lifecycle management of the worker management system.
5
+ * - Registers shutdown handlers
6
+ * - Initializes monitoring and resource management
7
+ * - Sets up auto-scaling and health checks
8
+ * - Ensures graceful startup and shutdown
9
+ */
10
+ import { Env, Logger, workersConfig } from '@zintrust/core';
11
+ import { ResourceMonitor } from './ResourceMonitor';
12
+ import { WorkerFactory } from './WorkerFactory';
13
+ import { WorkerShutdown } from './WorkerShutdown';
14
+ // ============================================================================
15
+ // State
16
+ // ============================================================================
17
+ const state = {
18
+ initialized: false,
19
+ initializedAt: null,
20
+ resourceMonitoring: false,
21
+ healthMonitoring: false,
22
+ autoScaling: false,
23
+ shutdownHandlersRegistered: false,
24
+ };
25
+ // ============================================================================
26
+ // Implementation
27
+ // ============================================================================
28
+ /**
29
+ * Initialize resource monitoring based on environment and worker settings
30
+ */
31
+ function initializeResourceMonitoring(enableResourceMonitoring, resourceMonitoringInterval) {
32
+ // Check global environment gate first
33
+ const globalResourceMonitoring = Env.getBool('WORKER_RESOURCE_MONITORING', false);
34
+ if (enableResourceMonitoring && globalResourceMonitoring) {
35
+ // Check if any workers have resourceMonitoring enabled
36
+ const shouldStart = shouldStartResourceMonitoring();
37
+ if (shouldStart) {
38
+ if (ResourceMonitor.isRunning() === false) {
39
+ ResourceMonitor.start(resourceMonitoringInterval / 1000);
40
+ }
41
+ Logger.debug('✓ Resource monitoring started (worker requested)');
42
+ return true;
43
+ }
44
+ else {
45
+ Logger.debug('⏸️ Resource monitoring disabled (no workers requested it)');
46
+ }
47
+ }
48
+ else if (!globalResourceMonitoring) {
49
+ Logger.debug('⏸️ Resource monitoring disabled (WORKER_RESOURCE_MONITORING=false)');
50
+ }
51
+ return false;
52
+ }
53
+ /**
54
+ * Check if any workers have resource monitoring enabled
55
+ */
56
+ function shouldStartResourceMonitoring() {
57
+ try {
58
+ const workerNames = WorkerFactory.list();
59
+ return workerNames.some((name) => {
60
+ const worker = WorkerFactory.get(name);
61
+ return worker?.config?.features?.resourceMonitoring === true;
62
+ });
63
+ }
64
+ catch {
65
+ return false;
66
+ }
67
+ }
68
+ /**
69
+ * Initialize the worker management system
70
+ */
71
+ async function initialize(options = {}) {
72
+ if (state.initialized) {
73
+ Logger.warn('Worker management system already initialized');
74
+ return;
75
+ }
76
+ const { enableResourceMonitoring = true, enableHealthMonitoring = true, enableAutoScaling = false, registerShutdownHandlers = true, resourceMonitoringInterval = 60000, } = options;
77
+ Logger.info('🚀 Initializing worker management system', {
78
+ enableResourceMonitoring,
79
+ enableHealthMonitoring,
80
+ enableAutoScaling,
81
+ registerShutdownHandlers,
82
+ });
83
+ try {
84
+ // 1. Register shutdown handlers first (so they're ready for any failures)
85
+ if (registerShutdownHandlers) {
86
+ WorkerShutdown.registerShutdownHandlers();
87
+ state.shutdownHandlersRegistered = true;
88
+ Logger.debug('✓ Shutdown handlers registered');
89
+ }
90
+ // 2. Start resource monitoring (important for scaling decisions)
91
+ state.resourceMonitoring = initializeResourceMonitoring(enableResourceMonitoring, resourceMonitoringInterval);
92
+ // 3. Enable health monitoring (depends on workers being created)
93
+ if (enableHealthMonitoring) {
94
+ // Health checks will start automatically when workers are created
95
+ state.healthMonitoring = true;
96
+ Logger.debug('✓ Health monitoring enabled');
97
+ }
98
+ // 4. Start auto-scaling if explicitly enabled
99
+ if (enableAutoScaling) {
100
+ // Auto-scaling will evaluate workers when they are created
101
+ state.autoScaling = true;
102
+ Logger.debug('✓ Auto-scaling enabled');
103
+ }
104
+ state.initialized = true;
105
+ state.initializedAt = new Date();
106
+ Logger.info('✅ Worker management system initialized successfully', {
107
+ timestamp: state.initializedAt.toISOString(),
108
+ });
109
+ }
110
+ catch (error) {
111
+ Logger.error('❌ Failed to initialize worker management system', error);
112
+ throw error;
113
+ }
114
+ }
115
+ async function autoStartPersistedWorkers() {
116
+ // Check if auto-start is enabled globally via environment variable
117
+ Logger.debug('Auto-start check', {
118
+ envAutoStart: process.env['WORKER_AUTO_START'],
119
+ configAutoStart: workersConfig.defaultWorker?.autoStart,
120
+ });
121
+ if (workersConfig.defaultWorker?.autoStart !== true) {
122
+ Logger.debug('Auto-start disabled - WORKER_AUTO_START is not true');
123
+ return;
124
+ }
125
+ try {
126
+ const records = await WorkerFactory.listPersistedRecords();
127
+ Logger.debug('Found persisted records', {
128
+ count: records.length,
129
+ records: records.map((r) => ({ name: r.name, autoStart: r.autoStart })),
130
+ });
131
+ const candidates = records.filter((record) => {
132
+ // If autoStart is explicitly true, always include
133
+ if (record.autoStart === true) {
134
+ return true;
135
+ }
136
+ // If autoStart is null or undefined and global auto-start is enabled, include
137
+ if ((record.autoStart === null || record.autoStart === undefined) &&
138
+ workersConfig.defaultWorker?.autoStart === true) {
139
+ return true;
140
+ }
141
+ return false;
142
+ });
143
+ Logger.debug('Auto-start candidates', {
144
+ count: candidates.length,
145
+ candidates: candidates.map((c) => c.name),
146
+ });
147
+ const results = await Promise.all(candidates.map(async (record) => {
148
+ if (WorkerFactory.get(record.name)) {
149
+ return { name: record.name, started: false, skipped: true };
150
+ }
151
+ try {
152
+ await WorkerFactory.startFromPersisted(record.name);
153
+ return { name: record.name, started: true, skipped: false };
154
+ }
155
+ catch (error) {
156
+ Logger.warn(`Auto-start failed for worker ${record.name}`, error);
157
+ return { name: record.name, started: false, skipped: false };
158
+ }
159
+ }));
160
+ const startedCount = results.filter((item) => item.started).length;
161
+ const skippedCount = results.filter((item) => item.skipped).length;
162
+ Logger.info('Auto-started persisted workers', {
163
+ total: candidates.length,
164
+ started: startedCount,
165
+ skipped: skippedCount,
166
+ });
167
+ }
168
+ catch (error) {
169
+ Logger.warn('Auto-start persisted workers failed', error);
170
+ }
171
+ }
172
+ /**
173
+ * Check if worker management system is initialized
174
+ */
175
+ function isInitialized() {
176
+ return state.initialized;
177
+ }
178
+ /**
179
+ * Get initialization state
180
+ */
181
+ function getInitState() {
182
+ return { ...state };
183
+ }
184
+ /**
185
+ * Graceful shutdown of worker management system
186
+ * (convenience method that delegates to WorkerShutdown)
187
+ */
188
+ async function shutdown() {
189
+ if (!state.initialized) {
190
+ Logger.warn('Worker management system not initialized, nothing to shutdown');
191
+ return;
192
+ }
193
+ await WorkerShutdown.shutdown();
194
+ state.initialized = false;
195
+ state.resourceMonitoring = false;
196
+ state.healthMonitoring = false;
197
+ state.autoScaling = false;
198
+ }
199
+ // ============================================================================
200
+ // Public API (Sealed Namespace)
201
+ // ============================================================================
202
+ export const WorkerInit = Object.freeze({
203
+ /**
204
+ * Initialize the worker management system
205
+ */
206
+ initialize,
207
+ /**
208
+ * Check if worker management system is initialized
209
+ */
210
+ isInitialized,
211
+ /**
212
+ * Get initialization state
213
+ */
214
+ getInitState,
215
+ /**
216
+ * Graceful shutdown of worker management system
217
+ */
218
+ shutdown,
219
+ /**
220
+ * Start persisted workers after boot completes
221
+ */
222
+ autoStartPersistedWorkers,
223
+ });
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Worker Metrics Manager
3
+ * Time-series metrics persistence with Redis Sorted Sets
4
+ * Sealed namespace for immutability
5
+ */
6
+ import { type RedisConfig } from '@zintrust/core';
7
+ export type MetricType = 'processed' | 'errors' | 'duration' | 'memory' | 'cpu' | 'queue-size' | 'active-jobs' | 'waiting-jobs' | 'delayed-jobs' | 'failed-jobs' | 'completed-jobs';
8
+ export type MetricGranularity = 'hourly' | 'daily' | 'monthly';
9
+ export type MetricPoint = {
10
+ timestamp: Date;
11
+ value: number;
12
+ metadata?: Record<string, unknown>;
13
+ };
14
+ export type MetricEntry = {
15
+ workerName: string;
16
+ metricType: MetricType;
17
+ granularity: MetricGranularity;
18
+ points: ReadonlyArray<MetricPoint>;
19
+ };
20
+ export type MetricQueryOptions = {
21
+ workerName: string;
22
+ metricType: MetricType;
23
+ granularity: MetricGranularity;
24
+ startDate?: Date;
25
+ endDate?: Date;
26
+ limit?: number;
27
+ };
28
+ export type AggregatedMetrics = {
29
+ workerName: string;
30
+ metricType: MetricType;
31
+ period: {
32
+ start: Date;
33
+ end: Date;
34
+ };
35
+ total: number;
36
+ average: number;
37
+ min: number;
38
+ max: number;
39
+ count: number;
40
+ };
41
+ export type WorkerHealthScore = {
42
+ workerName: string;
43
+ timestamp: Date;
44
+ score: number;
45
+ factors: {
46
+ errorRate: number;
47
+ throughput: number;
48
+ latency: number;
49
+ resourceUsage: number;
50
+ };
51
+ status: 'healthy' | 'degraded' | 'unhealthy';
52
+ };
53
+ /**
54
+ * Worker Metrics Manager - Sealed namespace
55
+ */
56
+ export declare const WorkerMetrics: Readonly<{
57
+ /**
58
+ * Initialize the metrics manager with Redis connection
59
+ */
60
+ initialize(config: RedisConfig): void;
61
+ /**
62
+ * Record a metric point
63
+ */
64
+ record(workerName: string, metricType: MetricType, value: number, metadata?: Record<string, unknown>): Promise<void>;
65
+ /**
66
+ * Record multiple metrics at once (batch operation)
67
+ */
68
+ recordBatch(workerName: string, metrics: Array<{
69
+ metricType: MetricType;
70
+ value: number;
71
+ metadata?: Record<string, unknown>;
72
+ }>): Promise<void>;
73
+ /**
74
+ * Query metrics for a time range
75
+ */
76
+ query(options: MetricQueryOptions): Promise<MetricEntry>;
77
+ /**
78
+ * Get aggregated metrics for a time range
79
+ */
80
+ aggregate(options: MetricQueryOptions): Promise<AggregatedMetrics>;
81
+ aggregateBatch(optionsList: MetricQueryOptions[]): Promise<AggregatedMetrics[]>;
82
+ /**
83
+ * Calculate and store health score
84
+ */
85
+ calculateHealth(workerName: string): Promise<WorkerHealthScore>;
86
+ /**
87
+ * Get recent health scores
88
+ */
89
+ getHealthHistory(workerName: string, hours?: number): Promise<ReadonlyArray<WorkerHealthScore>>;
90
+ /**
91
+ * Get latest health score
92
+ */
93
+ getLatestHealth(workerName: string): Promise<WorkerHealthScore | null>;
94
+ /**
95
+ * Get metrics summary for all workers
96
+ */
97
+ getAllWorkersSummary(): Promise<ReadonlyArray<{
98
+ workerName: string;
99
+ health: WorkerHealthScore | null;
100
+ metrics: {
101
+ processed: number;
102
+ errors: number;
103
+ errorRate: number;
104
+ };
105
+ }>>;
106
+ /**
107
+ * Delete all metrics for a worker
108
+ */
109
+ deleteWorkerMetrics(workerName: string): Promise<void>;
110
+ /**
111
+ * Shutdown and disconnect
112
+ */
113
+ shutdown(): Promise<void>;
114
+ }>;