bootifyjs 1.2.0 → 1.3.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/README.md +1 -1
- package/dist/api.d.ts +2 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +20 -4
- package/dist/api.js.map +1 -1
- package/dist/auth/examples/basic-usage.d.ts +2 -1
- package/dist/auth/examples/basic-usage.d.ts.map +1 -1
- package/dist/auth/examples/basic-usage.js +3 -2
- package/dist/auth/examples/basic-usage.js.map +1 -1
- package/dist/auth/index.d.ts +6 -8
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +11 -11
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/middleware/AuthMiddleware.js.map +1 -1
- package/dist/cache/bootstrap.js +1 -1
- package/dist/cache/bootstrap.js.map +1 -1
- package/dist/cache/index.d.ts +2 -1
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +4 -1
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/{in-memory-cache.store.d.ts → stores/in-memory-cache.store.d.ts} +1 -1
- package/dist/cache/stores/in-memory-cache.store.d.ts.map +1 -0
- package/dist/cache/{in-memory-cache.store.js → stores/in-memory-cache.store.js} +1 -1
- package/dist/cache/stores/in-memory-cache.store.js.map +1 -0
- package/dist/cache/stores/index.d.ts +3 -0
- package/dist/cache/stores/index.d.ts.map +1 -0
- package/dist/cache/stores/index.js +20 -0
- package/dist/cache/stores/index.js.map +1 -0
- package/dist/cache/stores/redis-cache.store.d.ts +8 -0
- package/dist/cache/stores/redis-cache.store.d.ts.map +1 -0
- package/dist/cache/stores/redis-cache.store.js +39 -0
- package/dist/cache/stores/redis-cache.store.js.map +1 -0
- package/dist/core/router.d.ts.map +1 -1
- package/dist/core/router.js +3 -3
- package/dist/core/router.js.map +1 -1
- package/dist/events/bootstrap.d.ts +13 -1
- package/dist/events/bootstrap.d.ts.map +1 -1
- package/dist/events/bootstrap.js +30 -2
- package/dist/events/bootstrap.js.map +1 -1
- package/dist/events/buffered-event-bus.service.d.ts +135 -0
- package/dist/events/buffered-event-bus.service.d.ts.map +1 -0
- package/dist/events/buffered-event-bus.service.js +420 -0
- package/dist/events/buffered-event-bus.service.js.map +1 -0
- package/dist/events/config/buffered-event-config.d.ts +153 -0
- package/dist/events/config/buffered-event-config.d.ts.map +1 -0
- package/dist/events/config/buffered-event-config.js +181 -0
- package/dist/events/config/buffered-event-config.js.map +1 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/metrics/event-metrics.d.ts +175 -0
- package/dist/events/metrics/event-metrics.d.ts.map +1 -0
- package/dist/events/metrics/event-metrics.js +235 -0
- package/dist/events/metrics/event-metrics.js.map +1 -0
- package/dist/events/monitoring/health-monitor.d.ts +142 -0
- package/dist/events/monitoring/health-monitor.d.ts.map +1 -0
- package/dist/events/monitoring/health-monitor.js +492 -0
- package/dist/events/monitoring/health-monitor.js.map +1 -0
- package/dist/events/retry/retry-handler.d.ts +112 -0
- package/dist/events/retry/retry-handler.d.ts.map +1 -0
- package/dist/events/retry/retry-handler.js +218 -0
- package/dist/events/retry/retry-handler.js.map +1 -0
- package/dist/events/shared-buffer.d.ts +92 -0
- package/dist/events/shared-buffer.d.ts.map +1 -0
- package/dist/events/shared-buffer.js +179 -0
- package/dist/events/shared-buffer.js.map +1 -0
- package/dist/events/worker/event-processor.worker.d.ts +75 -0
- package/dist/events/worker/event-processor.worker.d.ts.map +1 -0
- package/dist/events/worker/event-processor.worker.js +293 -0
- package/dist/events/worker/event-processor.worker.js.map +1 -0
- package/dist/events/worker/worker-manager.d.ts +132 -0
- package/dist/events/worker/worker-manager.d.ts.map +1 -0
- package/dist/events/worker/worker-manager.js +436 -0
- package/dist/events/worker/worker-manager.js.map +1 -0
- package/dist/examples/auth/auth.middleware.d.ts +0 -26
- package/dist/examples/auth/auth.middleware.d.ts.map +1 -1
- package/dist/examples/auth/auth.middleware.js +0 -185
- package/dist/examples/auth/auth.middleware.js.map +1 -1
- package/dist/examples/controllers/auth.controller.d.ts +0 -63
- package/dist/examples/controllers/auth.controller.d.ts.map +1 -1
- package/dist/examples/controllers/auth.controller.js +247 -282
- package/dist/examples/controllers/auth.controller.js.map +1 -1
- package/dist/examples/events/buffered-event-example.d.ts +71 -0
- package/dist/examples/events/buffered-event-example.d.ts.map +1 -0
- package/dist/examples/events/buffered-event-example.js +182 -0
- package/dist/examples/events/buffered-event-example.js.map +1 -0
- package/dist/examples/events/integration-test.d.ts +10 -0
- package/dist/examples/events/integration-test.d.ts.map +1 -0
- package/dist/examples/events/integration-test.js +147 -0
- package/dist/examples/events/integration-test.js.map +1 -0
- package/dist/examples/index.d.ts +1 -0
- package/dist/examples/index.d.ts.map +1 -1
- package/dist/examples/index.js +11 -7
- package/dist/examples/index.js.map +1 -1
- package/dist/examples/todos/schema.d.ts +4 -4
- package/package.json +2 -1
- package/dist/cache/in-memory-cache.store.d.ts.map +0 -1
- package/dist/cache/in-memory-cache.store.js.map +0 -1
- package/dist/examples/authorization-examples.d.ts +0 -67
- package/dist/examples/authorization-examples.d.ts.map +0 -1
- package/dist/examples/authorization-examples.js +0 -202
- package/dist/examples/authorization-examples.js.map +0 -1
- package/dist/examples/controllers/todo-updated.controller.d.ts +0 -103
- package/dist/examples/controllers/todo-updated.controller.d.ts.map +0 -1
- package/dist/examples/controllers/todo-updated.controller.js +0 -328
- package/dist/examples/controllers/todo-updated.controller.js.map +0 -1
- package/dist/examples/controllers/todo-with-jwt-auth.controller.d.ts +0 -114
- package/dist/examples/controllers/todo-with-jwt-auth.controller.d.ts.map +0 -1
- package/dist/examples/controllers/todo-with-jwt-auth.controller.js +0 -329
- package/dist/examples/controllers/todo-with-jwt-auth.controller.js.map +0 -1
- package/dist/examples/jwt-auth-example.d.ts +0 -47
- package/dist/examples/jwt-auth-example.d.ts.map +0 -1
- package/dist/examples/jwt-auth-example.js +0 -316
- package/dist/examples/jwt-auth-example.js.map +0 -1
- package/dist/examples/services/user.service.d.ts +0 -99
- package/dist/examples/services/user.service.d.ts.map +0 -1
- package/dist/examples/services/user.service.js +0 -281
- package/dist/examples/services/user.service.js.map +0 -1
- package/dist/examples/test-auth-flow.d.ts +0 -56
- package/dist/examples/test-auth-flow.d.ts.map +0 -1
- package/dist/examples/test-auth-flow.js +0 -449
- package/dist/examples/test-auth-flow.js.map +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { EventPriority } from '../shared-buffer';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for buffered event processing system
|
|
4
|
+
*/
|
|
5
|
+
export interface BufferedEventConfig {
|
|
6
|
+
/** Enable/disable buffered event processing */
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
/** Number of worker threads to spawn */
|
|
9
|
+
workerCount: number;
|
|
10
|
+
/** Maximum number of events in queue */
|
|
11
|
+
maxQueueSize: number;
|
|
12
|
+
/** Maximum memory allocation in MB */
|
|
13
|
+
maxMemoryMB: number;
|
|
14
|
+
/** Maximum size per event in bytes */
|
|
15
|
+
maxEventSize: number;
|
|
16
|
+
/** Maximum retry attempts before moving to DLQ */
|
|
17
|
+
retryAttempts: number;
|
|
18
|
+
/** Retry delays in milliseconds (exponential backoff) */
|
|
19
|
+
retryDelays: number[];
|
|
20
|
+
/** Priority configuration */
|
|
21
|
+
priorities: {
|
|
22
|
+
critical: number;
|
|
23
|
+
normal: number;
|
|
24
|
+
low: number;
|
|
25
|
+
};
|
|
26
|
+
/** Memory limits */
|
|
27
|
+
memoryLimits: MemoryLimits;
|
|
28
|
+
/** Performance limits */
|
|
29
|
+
performanceLimits: PerformanceLimits;
|
|
30
|
+
/** Reliability limits */
|
|
31
|
+
reliabilityLimits: ReliabilityLimits;
|
|
32
|
+
/** Monitoring configuration */
|
|
33
|
+
monitoring: MonitoringConfig;
|
|
34
|
+
/** Fallback to synchronous processing if workers fail */
|
|
35
|
+
fallbackToSync: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Memory constraint configuration
|
|
39
|
+
*/
|
|
40
|
+
export interface MemoryLimits {
|
|
41
|
+
/** Maximum events in buffer */
|
|
42
|
+
maxQueueSize: number;
|
|
43
|
+
/** Maximum size per event in bytes */
|
|
44
|
+
maxEventSize: number;
|
|
45
|
+
/** Total memory allocation in MB */
|
|
46
|
+
totalMemoryMB: number;
|
|
47
|
+
/** Per-worker heap limit in MB */
|
|
48
|
+
workerHeapMB: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Performance constraint configuration
|
|
52
|
+
*/
|
|
53
|
+
export interface PerformanceLimits {
|
|
54
|
+
/** Maximum input rate (events/sec) */
|
|
55
|
+
maxInputRate: number;
|
|
56
|
+
/** Target processing rate (events/sec) */
|
|
57
|
+
targetProcessingRate: number;
|
|
58
|
+
/** Maximum CPU usage on main thread (%) */
|
|
59
|
+
maxMainThreadImpact: number;
|
|
60
|
+
/** Maximum queue latency for 95th percentile (ms) */
|
|
61
|
+
maxQueueLatency: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Reliability constraint configuration
|
|
65
|
+
*/
|
|
66
|
+
export interface ReliabilityLimits {
|
|
67
|
+
/** Maximum retry attempts before DLQ */
|
|
68
|
+
maxRetryAttempts: number;
|
|
69
|
+
/** Delay before restarting failed worker (ms) */
|
|
70
|
+
workerRestartDelay: number;
|
|
71
|
+
/** Interval between health checks (ms) */
|
|
72
|
+
healthCheckInterval: number;
|
|
73
|
+
/** Timeout for graceful shutdown (ms) */
|
|
74
|
+
gracefulShutdownTimeout: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Monitoring and metrics configuration
|
|
78
|
+
*/
|
|
79
|
+
export interface MonitoringConfig {
|
|
80
|
+
/** Enable metrics collection */
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
/** Metrics collection interval (ms) */
|
|
83
|
+
metricsInterval: number;
|
|
84
|
+
/** Enable health monitoring */
|
|
85
|
+
healthMonitoring: boolean;
|
|
86
|
+
/** Health check interval (ms) */
|
|
87
|
+
healthCheckInterval: number;
|
|
88
|
+
/** Alert thresholds */
|
|
89
|
+
alertThresholds: AlertThresholds;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Alert threshold configuration
|
|
93
|
+
*/
|
|
94
|
+
export interface AlertThresholds {
|
|
95
|
+
/** Queue depth warning threshold */
|
|
96
|
+
queueDepthWarning: number;
|
|
97
|
+
/** Processing rate degradation threshold (events/sec) */
|
|
98
|
+
processingRateMin: number;
|
|
99
|
+
/** Maximum failed workers before alert */
|
|
100
|
+
maxFailedWorkers: number;
|
|
101
|
+
/** Dead letter queue size alert threshold */
|
|
102
|
+
dlqSizeAlert: number;
|
|
103
|
+
/** Main thread CPU usage alert threshold (%) */
|
|
104
|
+
mainThreadCpuAlert: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Default configuration for buffered event processing
|
|
108
|
+
*/
|
|
109
|
+
export declare const defaultBufferedEventConfig: BufferedEventConfig;
|
|
110
|
+
/**
|
|
111
|
+
* Configuration validator
|
|
112
|
+
*/
|
|
113
|
+
export declare class BufferedEventConfigValidator {
|
|
114
|
+
/**
|
|
115
|
+
* Validate configuration and return errors if any
|
|
116
|
+
*/
|
|
117
|
+
static validate(config: Partial<BufferedEventConfig>): string[];
|
|
118
|
+
/**
|
|
119
|
+
* Merge user config with defaults
|
|
120
|
+
*/
|
|
121
|
+
static mergeWithDefaults(userConfig: Partial<BufferedEventConfig>): BufferedEventConfig;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Environment-based configuration loader
|
|
125
|
+
*/
|
|
126
|
+
export declare class BufferedEventConfigLoader {
|
|
127
|
+
/**
|
|
128
|
+
* Load configuration from environment variables
|
|
129
|
+
*/
|
|
130
|
+
static fromEnvironment(): Partial<BufferedEventConfig>;
|
|
131
|
+
/**
|
|
132
|
+
* Load configuration from file
|
|
133
|
+
*/
|
|
134
|
+
static fromFile(filePath: string): Partial<BufferedEventConfig>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Priority helper functions
|
|
138
|
+
*/
|
|
139
|
+
export declare class PriorityHelper {
|
|
140
|
+
/**
|
|
141
|
+
* Get numeric priority value
|
|
142
|
+
*/
|
|
143
|
+
static getPriorityValue(priority: EventPriority, config: BufferedEventConfig): number;
|
|
144
|
+
/**
|
|
145
|
+
* Compare priorities (higher number = higher priority)
|
|
146
|
+
*/
|
|
147
|
+
static comparePriorities(a: EventPriority, b: EventPriority, config: BufferedEventConfig): number;
|
|
148
|
+
/**
|
|
149
|
+
* Check if priority is valid
|
|
150
|
+
*/
|
|
151
|
+
static isValidPriority(priority: string): priority is EventPriority;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=buffered-event-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffered-event-config.d.ts","sourceRoot":"","sources":["../../../src/events/config/buffered-event-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAC;IAEjB,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IAEpB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IAErB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IAEpB,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IAErB,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IAEtB,yDAAyD;IACzD,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,6BAA6B;IAC7B,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IAEF,oBAAoB;IACpB,YAAY,EAAE,Y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,iBAAiB,EAAE,MAAM,CAAC;IAE1B,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAC;IAE1B,0CAA0C;IAC1C,gBAAgB,EAAE,MAAM,CAAC;IAEzB,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IAErB,gDAAgD;IAChD,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,mBA6CxC,CAAC;AAEF;;GAEG;AACH,qBAAa,4BAA4B;IACvC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,MAAM,EAAE;IA8B/D;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;CA0BxF;AAED;;GAEG;AACH,qBAAa,yBAAyB;IACpC;;OAEG;IACH,MAAM,CAAC,eAAe,IAAI,OAAO,CAAC,mBAAmB,CAAC;IA0BtD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAUhE;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM;IAIrF;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM;IAMjG;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,aAAa;CAGpE"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PriorityHelper = exports.BufferedEventConfigLoader = exports.BufferedEventConfigValidator = exports.defaultBufferedEventConfig = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default configuration for buffered event processing
|
|
6
|
+
*/
|
|
7
|
+
exports.defaultBufferedEventConfig = {
|
|
8
|
+
enabled: true,
|
|
9
|
+
workerCount: 5,
|
|
10
|
+
maxQueueSize: 10000,
|
|
11
|
+
maxMemoryMB: 50,
|
|
12
|
+
maxEventSize: 5120, // 5KB
|
|
13
|
+
retryAttempts: 3,
|
|
14
|
+
retryDelays: [1000, 2000, 4000], // 1s, 2s, 4s
|
|
15
|
+
priorities: {
|
|
16
|
+
critical: 3,
|
|
17
|
+
normal: 2,
|
|
18
|
+
low: 1
|
|
19
|
+
},
|
|
20
|
+
memoryLimits: {
|
|
21
|
+
maxQueueSize: 10000,
|
|
22
|
+
maxEventSize: 5120,
|
|
23
|
+
totalMemoryMB: 50,
|
|
24
|
+
workerHeapMB: 100
|
|
25
|
+
},
|
|
26
|
+
performanceLimits: {
|
|
27
|
+
maxInputRate: 1000,
|
|
28
|
+
targetProcessingRate: 500,
|
|
29
|
+
maxMainThreadImpact: 5,
|
|
30
|
+
maxQueueLatency: 100
|
|
31
|
+
},
|
|
32
|
+
reliabilityLimits: {
|
|
33
|
+
maxRetryAttempts: 3,
|
|
34
|
+
workerRestartDelay: 1000,
|
|
35
|
+
healthCheckInterval: 5000,
|
|
36
|
+
gracefulShutdownTimeout: 10000
|
|
37
|
+
},
|
|
38
|
+
monitoring: {
|
|
39
|
+
enabled: true,
|
|
40
|
+
metricsInterval: 1000,
|
|
41
|
+
healthMonitoring: true,
|
|
42
|
+
healthCheckInterval: 5000,
|
|
43
|
+
alertThresholds: {
|
|
44
|
+
queueDepthWarning: 8000,
|
|
45
|
+
processingRateMin: 0, // Set to 0 to prevent alerts when no events are being processed
|
|
46
|
+
maxFailedWorkers: 1,
|
|
47
|
+
dlqSizeAlert: 100,
|
|
48
|
+
mainThreadCpuAlert: 10
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
fallbackToSync: true
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Configuration validator
|
|
55
|
+
*/
|
|
56
|
+
class BufferedEventConfigValidator {
|
|
57
|
+
/**
|
|
58
|
+
* Validate configuration and return errors if any
|
|
59
|
+
*/
|
|
60
|
+
static validate(config) {
|
|
61
|
+
const errors = [];
|
|
62
|
+
if (config.workerCount && (config.workerCount < 1 || config.workerCount > 20)) {
|
|
63
|
+
errors.push('workerCount must be between 1 and 20');
|
|
64
|
+
}
|
|
65
|
+
if (config.maxQueueSize && config.maxQueueSize < 100) {
|
|
66
|
+
errors.push('maxQueueSize must be at least 100');
|
|
67
|
+
}
|
|
68
|
+
if (config.maxEventSize && config.maxEventSize < 1024) {
|
|
69
|
+
errors.push('maxEventSize must be at least 1KB');
|
|
70
|
+
}
|
|
71
|
+
if (config.maxMemoryMB && config.maxMemoryMB < 10) {
|
|
72
|
+
errors.push('maxMemoryMB must be at least 10MB');
|
|
73
|
+
}
|
|
74
|
+
if (config.retryAttempts && (config.retryAttempts < 0 || config.retryAttempts > 10)) {
|
|
75
|
+
errors.push('retryAttempts must be between 0 and 10');
|
|
76
|
+
}
|
|
77
|
+
if (config.retryDelays && config.retryDelays.some(delay => delay < 100)) {
|
|
78
|
+
errors.push('All retry delays must be at least 100ms');
|
|
79
|
+
}
|
|
80
|
+
return errors;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Merge user config with defaults
|
|
84
|
+
*/
|
|
85
|
+
static mergeWithDefaults(userConfig) {
|
|
86
|
+
return {
|
|
87
|
+
...exports.defaultBufferedEventConfig,
|
|
88
|
+
...userConfig,
|
|
89
|
+
memoryLimits: {
|
|
90
|
+
...exports.defaultBufferedEventConfig.memoryLimits,
|
|
91
|
+
...userConfig.memoryLimits
|
|
92
|
+
},
|
|
93
|
+
performanceLimits: {
|
|
94
|
+
...exports.defaultBufferedEventConfig.performanceLimits,
|
|
95
|
+
...userConfig.performanceLimits
|
|
96
|
+
},
|
|
97
|
+
reliabilityLimits: {
|
|
98
|
+
...exports.defaultBufferedEventConfig.reliabilityLimits,
|
|
99
|
+
...userConfig.reliabilityLimits
|
|
100
|
+
},
|
|
101
|
+
monitoring: {
|
|
102
|
+
...exports.defaultBufferedEventConfig.monitoring,
|
|
103
|
+
...userConfig.monitoring,
|
|
104
|
+
alertThresholds: {
|
|
105
|
+
...exports.defaultBufferedEventConfig.monitoring.alertThresholds,
|
|
106
|
+
...userConfig.monitoring?.alertThresholds
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.BufferedEventConfigValidator = BufferedEventConfigValidator;
|
|
113
|
+
/**
|
|
114
|
+
* Environment-based configuration loader
|
|
115
|
+
*/
|
|
116
|
+
class BufferedEventConfigLoader {
|
|
117
|
+
/**
|
|
118
|
+
* Load configuration from environment variables
|
|
119
|
+
*/
|
|
120
|
+
static fromEnvironment() {
|
|
121
|
+
const config = {};
|
|
122
|
+
if (process.env.BUFFERED_EVENTS_ENABLED) {
|
|
123
|
+
config.enabled = process.env.BUFFERED_EVENTS_ENABLED === 'true';
|
|
124
|
+
}
|
|
125
|
+
if (process.env.BUFFERED_EVENTS_WORKER_COUNT) {
|
|
126
|
+
config.workerCount = parseInt(process.env.BUFFERED_EVENTS_WORKER_COUNT, 10);
|
|
127
|
+
}
|
|
128
|
+
if (process.env.BUFFERED_EVENTS_MAX_QUEUE_SIZE) {
|
|
129
|
+
config.maxQueueSize = parseInt(process.env.BUFFERED_EVENTS_MAX_QUEUE_SIZE, 10);
|
|
130
|
+
}
|
|
131
|
+
if (process.env.BUFFERED_EVENTS_MAX_MEMORY_MB) {
|
|
132
|
+
config.maxMemoryMB = parseInt(process.env.BUFFERED_EVENTS_MAX_MEMORY_MB, 10);
|
|
133
|
+
}
|
|
134
|
+
if (process.env.BUFFERED_EVENTS_RETRY_ATTEMPTS) {
|
|
135
|
+
config.retryAttempts = parseInt(process.env.BUFFERED_EVENTS_RETRY_ATTEMPTS, 10);
|
|
136
|
+
}
|
|
137
|
+
return config;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Load configuration from file
|
|
141
|
+
*/
|
|
142
|
+
static fromFile(filePath) {
|
|
143
|
+
try {
|
|
144
|
+
const fs = require('fs');
|
|
145
|
+
const configData = fs.readFileSync(filePath, 'utf8');
|
|
146
|
+
return JSON.parse(configData);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
console.warn(`Failed to load buffered event config from ${filePath}:`, error);
|
|
150
|
+
return {};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.BufferedEventConfigLoader = BufferedEventConfigLoader;
|
|
155
|
+
/**
|
|
156
|
+
* Priority helper functions
|
|
157
|
+
*/
|
|
158
|
+
class PriorityHelper {
|
|
159
|
+
/**
|
|
160
|
+
* Get numeric priority value
|
|
161
|
+
*/
|
|
162
|
+
static getPriorityValue(priority, config) {
|
|
163
|
+
return config.priorities[priority] || config.priorities.normal;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Compare priorities (higher number = higher priority)
|
|
167
|
+
*/
|
|
168
|
+
static comparePriorities(a, b, config) {
|
|
169
|
+
const priorityA = this.getPriorityValue(a, config);
|
|
170
|
+
const priorityB = this.getPriorityValue(b, config);
|
|
171
|
+
return priorityB - priorityA; // Higher priority first
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Check if priority is valid
|
|
175
|
+
*/
|
|
176
|
+
static isValidPriority(priority) {
|
|
177
|
+
return ['critical', 'normal', 'low'].includes(priority);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.PriorityHelper = PriorityHelper;
|
|
181
|
+
//# sourceMappingURL=buffered-event-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffered-event-config.js","sourceRoot":"","sources":["../../../src/events/config/buffered-event-config.ts"],"names":[],"mappings":";;;AA6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index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './bootstrap';
|
|
2
2
|
export * from './event-bus.service';
|
|
3
|
+
export * from './buffered-event-bus.service';
|
|
3
4
|
export * from './event.types';
|
|
4
5
|
export * from './decorators';
|
|
6
|
+
export * from './shared-buffer';
|
|
7
|
+
export * from './config/buffered-event-config';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gCAAgC,CAAA"}
|
package/dist/events/index.js
CHANGED
|
@@ -16,6 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./bootstrap"), exports);
|
|
18
18
|
__exportStar(require("./event-bus.service"), exports);
|
|
19
|
+
__exportStar(require("./buffered-event-bus.service"), exports);
|
|
19
20
|
__exportStar(require("./event.types"), exports);
|
|
20
21
|
__exportStar(require("./decorators"), exports);
|
|
22
|
+
__exportStar(require("./shared-buffer"), exports);
|
|
23
|
+
__exportStar(require("./config/buffered-event-config"), exports);
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
package/dist/events/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,sDAAmC;AACnC,gDAA6B;AAC7B,+CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,sDAAmC;AACnC,+DAA4C;AAC5C,gDAA6B;AAC7B,+CAA4B;AAC5B,kDAA+B;AAC/B,iEAA8C"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { EventPriority } from '../shared-buffer';
|
|
2
|
+
import { BufferedEventConfig } from '../config/buffered-event-config';
|
|
3
|
+
import { RetryStats } from '../retry/retry-handler';
|
|
4
|
+
/**
|
|
5
|
+
* Worker status information
|
|
6
|
+
*/
|
|
7
|
+
export interface WorkerStatus {
|
|
8
|
+
id: string;
|
|
9
|
+
pid: number;
|
|
10
|
+
status: 'running' | 'idle' | 'error' | 'restarting';
|
|
11
|
+
eventsProcessed: number;
|
|
12
|
+
lastActivity: number;
|
|
13
|
+
memoryUsage: number;
|
|
14
|
+
cpuUsage: number;
|
|
15
|
+
errors: number;
|
|
16
|
+
uptime: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Queue metrics by priority
|
|
20
|
+
*/
|
|
21
|
+
export interface PriorityQueueMetrics {
|
|
22
|
+
critical: number;
|
|
23
|
+
normal: number;
|
|
24
|
+
low: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Performance metrics
|
|
28
|
+
*/
|
|
29
|
+
export interface PerformanceMetrics {
|
|
30
|
+
/** Average processing time per event (ms) */
|
|
31
|
+
averageProcessingTime: number;
|
|
32
|
+
/** 95th percentile processing time (ms) */
|
|
33
|
+
p95ProcessingTime: number;
|
|
34
|
+
/** Queue latency (time from enqueue to dequeue) */
|
|
35
|
+
averageQueueLatency: number;
|
|
36
|
+
/** Throughput metrics */
|
|
37
|
+
inputRate: number;
|
|
38
|
+
processingRate: number;
|
|
39
|
+
/** Main thread impact */
|
|
40
|
+
mainThreadCpuUsage: number;
|
|
41
|
+
mainThreadMemoryUsage: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Comprehensive event system metrics
|
|
45
|
+
*/
|
|
46
|
+
export interface EventMetrics {
|
|
47
|
+
/** Timestamp of metrics collection */
|
|
48
|
+
timestamp: number;
|
|
49
|
+
/** Queue metrics */
|
|
50
|
+
queueDepth: number;
|
|
51
|
+
queueDepthByPriority: PriorityQueueMetrics;
|
|
52
|
+
queueUtilization: number;
|
|
53
|
+
/** Throughput metrics */
|
|
54
|
+
eventsEnqueued: number;
|
|
55
|
+
eventsProcessed: number;
|
|
56
|
+
eventsDropped: number;
|
|
57
|
+
processingRate: number;
|
|
58
|
+
/** Performance metrics */
|
|
59
|
+
performance: PerformanceMetrics;
|
|
60
|
+
/** Worker health */
|
|
61
|
+
activeWorkers: number;
|
|
62
|
+
failedWorkers: number;
|
|
63
|
+
workerStatuses: WorkerStatus[];
|
|
64
|
+
/** Error metrics */
|
|
65
|
+
errorRate: number;
|
|
66
|
+
deadLetterQueueSize: number;
|
|
67
|
+
retryStats: RetryStats;
|
|
68
|
+
/** Resource usage */
|
|
69
|
+
memoryUsage: number;
|
|
70
|
+
totalMemoryAllocated: number;
|
|
71
|
+
memoryUtilization: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Bottleneck detection report
|
|
75
|
+
*/
|
|
76
|
+
export interface BottleneckReport {
|
|
77
|
+
detected: boolean;
|
|
78
|
+
type: 'queue_full' | 'slow_processing' | 'worker_failure' | 'memory_pressure' | 'none';
|
|
79
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
80
|
+
description: string;
|
|
81
|
+
recommendations: string[];
|
|
82
|
+
metrics: Partial<EventMetrics>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Optimization hints
|
|
86
|
+
*/
|
|
87
|
+
export interface OptimizationHint {
|
|
88
|
+
type: 'scale_workers' | 'increase_memory' | 'optimize_handlers' | 'adjust_priorities';
|
|
89
|
+
priority: 'low' | 'medium' | 'high';
|
|
90
|
+
description: string;
|
|
91
|
+
expectedImpact: string;
|
|
92
|
+
implementation: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Event metrics collector and analyzer
|
|
96
|
+
*/
|
|
97
|
+
export declare class EventMetricsCollector {
|
|
98
|
+
private config;
|
|
99
|
+
private metricsHistory;
|
|
100
|
+
private maxHistorySize;
|
|
101
|
+
private eventsEnqueued;
|
|
102
|
+
private eventsProcessed;
|
|
103
|
+
private eventsDropped;
|
|
104
|
+
private processingTimes;
|
|
105
|
+
private queueLatencies;
|
|
106
|
+
private workerStatuses;
|
|
107
|
+
private lastMetricsTime;
|
|
108
|
+
private lastEventsProcessed;
|
|
109
|
+
constructor(config: BufferedEventConfig);
|
|
110
|
+
/**
|
|
111
|
+
* Record event enqueued
|
|
112
|
+
*/
|
|
113
|
+
recordEventEnqueued(priority?: EventPriority): void;
|
|
114
|
+
/**
|
|
115
|
+
* Record event processed
|
|
116
|
+
*/
|
|
117
|
+
recordEventProcessed(processingTime: number, queueLatency: number): void;
|
|
118
|
+
/**
|
|
119
|
+
* Record event dropped
|
|
120
|
+
*/
|
|
121
|
+
recordEventDropped(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Update worker status
|
|
124
|
+
*/
|
|
125
|
+
updateWorkerStatus(workerId: string, status: Partial<WorkerStatus>): void;
|
|
126
|
+
/**
|
|
127
|
+
* Collect current metrics
|
|
128
|
+
*/
|
|
129
|
+
collectMetrics(queueDepth: number, queueDepthByPriority: PriorityQueueMetrics, memoryUsage: number, retryStats: RetryStats, deadLetterQueueSize: number): EventMetrics;
|
|
130
|
+
/**
|
|
131
|
+
* Calculate performance metrics
|
|
132
|
+
*/
|
|
133
|
+
private calculatePerformanceMetrics;
|
|
134
|
+
/**
|
|
135
|
+
* Calculate percentile from array of numbers
|
|
136
|
+
*/
|
|
137
|
+
private calculatePercentile;
|
|
138
|
+
/**
|
|
139
|
+
* Calculate rate from metrics history
|
|
140
|
+
*/
|
|
141
|
+
private calculateRate;
|
|
142
|
+
/**
|
|
143
|
+
* Estimate main thread CPU usage (simplified)
|
|
144
|
+
*/
|
|
145
|
+
private estimateMainThreadCpuUsage;
|
|
146
|
+
/**
|
|
147
|
+
* Get queue depth by priority
|
|
148
|
+
*/
|
|
149
|
+
getQueueDepthByPriority(): PriorityQueueMetrics;
|
|
150
|
+
/**
|
|
151
|
+
* Get metrics history
|
|
152
|
+
*/
|
|
153
|
+
getMetricsHistory(limit?: number): EventMetrics[];
|
|
154
|
+
/**
|
|
155
|
+
* Reset counters
|
|
156
|
+
*/
|
|
157
|
+
resetCounters(): void;
|
|
158
|
+
/**
|
|
159
|
+
* Clear metrics history
|
|
160
|
+
*/
|
|
161
|
+
clearHistory(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Get current worker count
|
|
164
|
+
*/
|
|
165
|
+
getWorkerCount(): {
|
|
166
|
+
active: number;
|
|
167
|
+
failed: number;
|
|
168
|
+
total: number;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Remove worker from tracking
|
|
172
|
+
*/
|
|
173
|
+
removeWorker(workerId: string): void;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=event-metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-metrics.d.ts","sourceRoot":"","sources":["../../../src/events/metrics/event-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,SAAS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