pp-command-bus 1.5.0 → 2.0.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 +400 -1219
- package/dist/command-bus/command-bus.spec.js +138 -359
- package/dist/command-bus/command-bus.spec.js.map +1 -1
- package/dist/command-bus/command.d.ts +3 -4
- package/dist/command-bus/command.js +3 -32
- package/dist/command-bus/command.js.map +1 -1
- package/dist/command-bus/config/command-bus-config.d.ts +75 -21
- package/dist/command-bus/config/command-bus-config.js +99 -58
- package/dist/command-bus/config/command-bus-config.js.map +1 -1
- package/dist/command-bus/config/command-bus-config.spec.js +174 -100
- package/dist/command-bus/config/command-bus-config.spec.js.map +1 -1
- package/dist/command-bus/index.d.ts +39 -52
- package/dist/command-bus/index.js +133 -126
- package/dist/command-bus/index.js.map +1 -1
- package/dist/command-bus/logging/command-logger.d.ts +2 -0
- package/dist/command-bus/logging/command-logger.js +7 -0
- package/dist/command-bus/logging/command-logger.js.map +1 -1
- package/dist/command-bus/logging/command-logger.spec.js +36 -0
- package/dist/command-bus/logging/command-logger.spec.js.map +1 -1
- package/dist/command-bus/serialization/index.d.ts +6 -0
- package/dist/command-bus/serialization/index.js +9 -0
- package/dist/command-bus/serialization/index.js.map +1 -0
- package/dist/command-bus/serialization/msgpack-serializer.d.ts +26 -0
- package/dist/command-bus/serialization/msgpack-serializer.js +70 -0
- package/dist/command-bus/serialization/msgpack-serializer.js.map +1 -0
- package/dist/command-bus/serialization/msgpack-serializer.spec.js +223 -0
- package/dist/command-bus/serialization/msgpack-serializer.spec.js.map +1 -0
- package/dist/command-bus/serialization/serializer.interface.d.ts +21 -0
- package/dist/command-bus/serialization/serializer.interface.js +3 -0
- package/dist/command-bus/serialization/serializer.interface.js.map +1 -0
- package/dist/command-bus/transport/consumer-loop.d.ts +45 -0
- package/dist/command-bus/transport/consumer-loop.js +90 -0
- package/dist/command-bus/transport/consumer-loop.js.map +1 -0
- package/dist/command-bus/transport/consumer-loop.spec.js +216 -0
- package/dist/command-bus/transport/consumer-loop.spec.js.map +1 -0
- package/dist/command-bus/transport/index.d.ts +21 -0
- package/dist/command-bus/transport/index.js +23 -0
- package/dist/command-bus/transport/index.js.map +1 -0
- package/dist/command-bus/transport/message-processor.d.ts +59 -0
- package/dist/command-bus/transport/message-processor.js +111 -0
- package/dist/command-bus/transport/message-processor.js.map +1 -0
- package/dist/command-bus/transport/message-processor.spec.js +185 -0
- package/dist/command-bus/transport/message-processor.spec.js.map +1 -0
- package/dist/command-bus/transport/pending-recovery.d.ts +54 -0
- package/dist/command-bus/transport/pending-recovery.js +139 -0
- package/dist/command-bus/transport/pending-recovery.js.map +1 -0
- package/dist/command-bus/transport/pending-recovery.spec.js +176 -0
- package/dist/command-bus/transport/pending-recovery.spec.js.map +1 -0
- package/dist/command-bus/transport/redis-codec.d.ts +24 -0
- package/dist/command-bus/transport/redis-codec.js +33 -0
- package/dist/command-bus/transport/redis-codec.js.map +1 -0
- package/dist/command-bus/transport/redis-codec.spec.js +53 -0
- package/dist/command-bus/transport/redis-codec.spec.js.map +1 -0
- package/dist/command-bus/transport/redis-streams-transport.d.ts +91 -0
- package/dist/command-bus/transport/redis-streams-transport.js +134 -0
- package/dist/command-bus/transport/redis-streams-transport.js.map +1 -0
- package/dist/command-bus/transport/redis-streams-transport.spec.js +420 -0
- package/dist/command-bus/transport/redis-streams-transport.spec.js.map +1 -0
- package/dist/command-bus/transport/rpc-handler.d.ts +39 -0
- package/dist/command-bus/transport/rpc-handler.js +87 -0
- package/dist/command-bus/transport/rpc-handler.js.map +1 -0
- package/dist/command-bus/transport/rpc-handler.spec.js +157 -0
- package/dist/command-bus/transport/rpc-handler.spec.js.map +1 -0
- package/dist/command-bus/transport/stream-consumer.d.ts +89 -0
- package/dist/command-bus/transport/stream-consumer.js +181 -0
- package/dist/command-bus/transport/stream-consumer.js.map +1 -0
- package/dist/command-bus/transport/stream-consumer.spec.js +284 -0
- package/dist/command-bus/transport/stream-consumer.spec.js.map +1 -0
- package/dist/command-bus/transport/stream-producer.d.ts +23 -0
- package/dist/command-bus/transport/stream-producer.js +70 -0
- package/dist/command-bus/transport/stream-producer.js.map +1 -0
- package/dist/command-bus/transport/stream-producer.spec.js +125 -0
- package/dist/command-bus/transport/stream-producer.spec.js.map +1 -0
- package/dist/command-bus/transport/transport.interface.d.ts +87 -0
- package/dist/command-bus/transport/transport.interface.js +3 -0
- package/dist/command-bus/transport/transport.interface.js.map +1 -0
- package/dist/command-bus/types/index.d.ts +0 -84
- package/dist/examples/rpc.demo.js +1 -1
- package/dist/examples/rpc.demo.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/pp-command-bus-2.0.0.tgz +0 -0
- package/dist/shared/redis/connection-pool.d.ts +54 -0
- package/dist/shared/redis/connection-pool.js +117 -0
- package/dist/shared/redis/connection-pool.js.map +1 -0
- package/dist/shared/redis/connection-pool.spec.js +114 -0
- package/dist/shared/redis/connection-pool.spec.js.map +1 -0
- package/dist/shared/redis/index.d.ts +5 -3
- package/dist/shared/redis/index.js +6 -4
- package/dist/shared/redis/index.js.map +1 -1
- package/dist/shared/redis/rpc-connection-pool.d.ts +61 -0
- package/dist/shared/redis/rpc-connection-pool.js +154 -0
- package/dist/shared/redis/rpc-connection-pool.js.map +1 -0
- package/dist/shared/redis/rpc-connection-pool.spec.d.ts +1 -0
- package/dist/shared/redis/rpc-connection-pool.spec.js +173 -0
- package/dist/shared/redis/rpc-connection-pool.spec.js.map +1 -0
- package/dist/shared/types.d.ts +0 -4
- package/dist/shared/utils/error-utils.d.ts +8 -0
- package/dist/shared/utils/error-utils.js +14 -0
- package/dist/shared/utils/error-utils.js.map +1 -0
- package/package.json +12 -12
- package/dist/command-bus/config/auto-config-optimizer.d.ts +0 -35
- package/dist/command-bus/config/auto-config-optimizer.js +0 -52
- package/dist/command-bus/config/auto-config-optimizer.js.map +0 -1
- package/dist/command-bus/config/auto-config-optimizer.spec.js +0 -42
- package/dist/command-bus/config/auto-config-optimizer.spec.js.map +0 -1
- package/dist/command-bus/job/index.d.ts +0 -6
- package/dist/command-bus/job/index.js +0 -15
- package/dist/command-bus/job/index.js.map +0 -1
- package/dist/command-bus/job/job-options-builder.d.ts +0 -21
- package/dist/command-bus/job/job-options-builder.js +0 -58
- package/dist/command-bus/job/job-options-builder.js.map +0 -1
- package/dist/command-bus/job/job-options-builder.spec.js +0 -156
- package/dist/command-bus/job/job-options-builder.spec.js.map +0 -1
- package/dist/command-bus/job/job-processor.d.ts +0 -39
- package/dist/command-bus/job/job-processor.js +0 -203
- package/dist/command-bus/job/job-processor.js.map +0 -1
- package/dist/command-bus/job/job-processor.spec.js +0 -436
- package/dist/command-bus/job/job-processor.spec.js.map +0 -1
- package/dist/command-bus/queue/index.d.ts +0 -5
- package/dist/command-bus/queue/index.js +0 -13
- package/dist/command-bus/queue/index.js.map +0 -1
- package/dist/command-bus/queue/queue-manager.d.ts +0 -56
- package/dist/command-bus/queue/queue-manager.js +0 -163
- package/dist/command-bus/queue/queue-manager.js.map +0 -1
- package/dist/command-bus/queue/queue-manager.spec.js +0 -371
- package/dist/command-bus/queue/queue-manager.spec.js.map +0 -1
- package/dist/command-bus/rpc/index.d.ts +0 -11
- package/dist/command-bus/rpc/index.js +0 -19
- package/dist/command-bus/rpc/index.js.map +0 -1
- package/dist/command-bus/rpc/payload-compression.service.d.ts +0 -50
- package/dist/command-bus/rpc/payload-compression.service.js +0 -215
- package/dist/command-bus/rpc/payload-compression.service.js.map +0 -1
- package/dist/command-bus/rpc/payload-compression.service.spec.js +0 -376
- package/dist/command-bus/rpc/payload-compression.service.spec.js.map +0 -1
- package/dist/command-bus/rpc/rpc-coordinator.d.ts +0 -96
- package/dist/command-bus/rpc/rpc-coordinator.js +0 -500
- package/dist/command-bus/rpc/rpc-coordinator.js.map +0 -1
- package/dist/command-bus/rpc/rpc-coordinator.spec.js +0 -621
- package/dist/command-bus/rpc/rpc-coordinator.spec.js.map +0 -1
- package/dist/command-bus/rpc/rpc-job-cancellation.service.d.ts +0 -82
- package/dist/command-bus/rpc/rpc-job-cancellation.service.js +0 -180
- package/dist/command-bus/rpc/rpc-job-cancellation.service.js.map +0 -1
- package/dist/command-bus/rpc/rpc-job-cancellation.service.spec.js +0 -286
- package/dist/command-bus/rpc/rpc-job-cancellation.service.spec.js.map +0 -1
- package/dist/command-bus/worker/index.d.ts +0 -10
- package/dist/command-bus/worker/index.js +0 -19
- package/dist/command-bus/worker/index.js.map +0 -1
- package/dist/command-bus/worker/worker-benchmark.d.ts +0 -71
- package/dist/command-bus/worker/worker-benchmark.js +0 -202
- package/dist/command-bus/worker/worker-benchmark.js.map +0 -1
- package/dist/command-bus/worker/worker-benchmark.spec.js +0 -310
- package/dist/command-bus/worker/worker-benchmark.spec.js.map +0 -1
- package/dist/command-bus/worker/worker-metrics-collector.d.ts +0 -98
- package/dist/command-bus/worker/worker-metrics-collector.js +0 -242
- package/dist/command-bus/worker/worker-metrics-collector.js.map +0 -1
- package/dist/command-bus/worker/worker-orchestrator.d.ts +0 -70
- package/dist/command-bus/worker/worker-orchestrator.js +0 -339
- package/dist/command-bus/worker/worker-orchestrator.js.map +0 -1
- package/dist/command-bus/worker/worker-orchestrator.spec.js +0 -712
- package/dist/command-bus/worker/worker-orchestrator.spec.js.map +0 -1
- package/dist/examples/auto-config.demo.d.ts +0 -9
- package/dist/examples/auto-config.demo.js +0 -106
- package/dist/examples/auto-config.demo.js.map +0 -1
- package/dist/examples/rpc-compression.demo.d.ts +0 -5
- package/dist/examples/rpc-compression.demo.js +0 -358
- package/dist/examples/rpc-compression.demo.js.map +0 -1
- package/dist/examples/rpc-resilience.demo.d.ts +0 -15
- package/dist/examples/rpc-resilience.demo.js +0 -233
- package/dist/examples/rpc-resilience.demo.js.map +0 -1
- package/dist/pp-command-bus-1.5.0.tgz +0 -0
- package/dist/shared/config/base-config.d.ts +0 -54
- package/dist/shared/config/base-config.js +0 -114
- package/dist/shared/config/base-config.js.map +0 -1
- package/dist/shared/config/base-config.spec.js +0 -204
- package/dist/shared/config/base-config.spec.js.map +0 -1
- package/dist/shared/config/index.d.ts +0 -1
- package/dist/shared/config/index.js +0 -9
- package/dist/shared/config/index.js.map +0 -1
- package/dist/shared/redis/redis-connection-factory.d.ts +0 -66
- package/dist/shared/redis/redis-connection-factory.js +0 -113
- package/dist/shared/redis/redis-connection-factory.js.map +0 -1
- /package/dist/command-bus/{config/auto-config-optimizer.spec.d.ts → serialization/msgpack-serializer.spec.d.ts} +0 -0
- /package/dist/command-bus/{job/job-options-builder.spec.d.ts → transport/consumer-loop.spec.d.ts} +0 -0
- /package/dist/command-bus/{job/job-processor.spec.d.ts → transport/message-processor.spec.d.ts} +0 -0
- /package/dist/command-bus/{queue/queue-manager.spec.d.ts → transport/pending-recovery.spec.d.ts} +0 -0
- /package/dist/command-bus/{rpc/payload-compression.service.spec.d.ts → transport/redis-codec.spec.d.ts} +0 -0
- /package/dist/command-bus/{rpc/rpc-coordinator.spec.d.ts → transport/redis-streams-transport.spec.d.ts} +0 -0
- /package/dist/command-bus/{rpc/rpc-job-cancellation.service.spec.d.ts → transport/rpc-handler.spec.d.ts} +0 -0
- /package/dist/command-bus/{worker/worker-benchmark.spec.d.ts → transport/stream-consumer.spec.d.ts} +0 -0
- /package/dist/command-bus/{worker/worker-orchestrator.spec.d.ts → transport/stream-producer.spec.d.ts} +0 -0
- /package/dist/shared/{config/base-config.spec.d.ts → redis/connection-pool.spec.d.ts} +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const ioredis_1 = require("ioredis");
|
|
13
|
+
const redis_error_formatter_1 = require("./redis-error-formatter");
|
|
14
|
+
/**
|
|
15
|
+
* Bounded, lazy pula połączeń dla operacji blokujących (BRPOP)
|
|
16
|
+
*
|
|
17
|
+
* Każde aktywne wywołanie RPC potrzebuje dedykowanego połączenia,
|
|
18
|
+
* ponieważ BRPOP blokuje cały socket do momentu odpowiedzi lub timeout.
|
|
19
|
+
*
|
|
20
|
+
* Połączenia tworzone leniwie przy acquire() i reużywane po release().
|
|
21
|
+
* Jeśli limit osiągnięty — caller czeka na wolne połączenie.
|
|
22
|
+
*
|
|
23
|
+
* DragonflyDB obsługuje tysiące połączeń efektywnie (multi-threaded),
|
|
24
|
+
* więc 50 concurrent BRPOP = ~100KB pamięci + 50 TCP socketów.
|
|
25
|
+
*/
|
|
26
|
+
class RpcConnectionPool {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.options = options;
|
|
29
|
+
this.available = [];
|
|
30
|
+
this.active = 0;
|
|
31
|
+
this.waiting = [];
|
|
32
|
+
/** Wypożyczone połączenia — śledzone do zamknięcia w close() */
|
|
33
|
+
this.borrowed = new Set();
|
|
34
|
+
this.closed = false;
|
|
35
|
+
if (options.maxSize < 1) {
|
|
36
|
+
throw new Error('Maksymalny rozmiar puli RPC musi wynosić co najmniej 1');
|
|
37
|
+
}
|
|
38
|
+
options.logger.debug('Pula połączeń RPC utworzona', {
|
|
39
|
+
maxSize: options.maxSize,
|
|
40
|
+
timestamp: new Date().toISOString(),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Pobiera połączenie z puli (lazy init, czeka jeśli limit osiągnięty)
|
|
45
|
+
* Caller MUSI wywołać release() po zakończeniu BRPOP
|
|
46
|
+
*/
|
|
47
|
+
acquire() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
if (this.closed) {
|
|
50
|
+
throw new Error('Pula połączeń RPC jest zamknięta');
|
|
51
|
+
}
|
|
52
|
+
// Spróbuj użyć wolnego połączenia
|
|
53
|
+
const free = this.available.pop();
|
|
54
|
+
if (free) {
|
|
55
|
+
this.active++;
|
|
56
|
+
this.borrowed.add(free);
|
|
57
|
+
return free;
|
|
58
|
+
}
|
|
59
|
+
// Stwórz nowe jeśli limit nie osiągnięty
|
|
60
|
+
if (this.active < this.options.maxSize) {
|
|
61
|
+
this.active++;
|
|
62
|
+
const conn = new ioredis_1.Redis(Object.assign(Object.assign({}, this.options.redisOptions), { maxRetriesPerRequest: null }));
|
|
63
|
+
this.setupEventHandlers(conn, `RpcPool[${this.active}]`);
|
|
64
|
+
this.borrowed.add(conn);
|
|
65
|
+
return conn;
|
|
66
|
+
}
|
|
67
|
+
// Limit osiągnięty — czekaj na release
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
this.waiting.push({ resolve, reject });
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Zwraca połączenie do puli
|
|
75
|
+
* Jeśli ktoś czeka — oddaje mu połączenie bez odkładania do available
|
|
76
|
+
*/
|
|
77
|
+
release(conn) {
|
|
78
|
+
this.active--;
|
|
79
|
+
this.borrowed.delete(conn);
|
|
80
|
+
// Jeśli pula zamknięta — zamknij zwrócone połączenie zamiast odkładać do available
|
|
81
|
+
if (this.closed) {
|
|
82
|
+
conn.disconnect();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const next = this.waiting.shift();
|
|
86
|
+
if (next) {
|
|
87
|
+
this.active++;
|
|
88
|
+
this.borrowed.add(conn);
|
|
89
|
+
next.resolve(conn);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.available.push(conn);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Zwraca liczbę aktywnych (wypożyczonych) połączeń
|
|
96
|
+
*/
|
|
97
|
+
get activeCount() {
|
|
98
|
+
return this.active;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Zwraca liczbę czekających na połączenie
|
|
102
|
+
*/
|
|
103
|
+
get waitingCount() {
|
|
104
|
+
return this.waiting.length;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Zamyka wszystkie połączenia w puli
|
|
108
|
+
*/
|
|
109
|
+
close() {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
if (this.closed)
|
|
112
|
+
return;
|
|
113
|
+
this.closed = true;
|
|
114
|
+
// Odrzuć czekających — reject ich promises żeby nie wisieli w pamięci
|
|
115
|
+
const closeError = new Error('Pula połączeń RPC została zamknięta');
|
|
116
|
+
while (this.waiting.length > 0) {
|
|
117
|
+
const waiter = this.waiting.shift();
|
|
118
|
+
if (waiter) {
|
|
119
|
+
waiter.reject(closeError);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
this.options.logger.debug('Zamykanie puli połączeń RPC', {
|
|
123
|
+
available: this.available.length,
|
|
124
|
+
active: this.active,
|
|
125
|
+
borrowed: this.borrowed.size,
|
|
126
|
+
timestamp: new Date().toISOString(),
|
|
127
|
+
});
|
|
128
|
+
// Zamknij wolne połączenia gracefully
|
|
129
|
+
yield Promise.all(this.available.map((c) => c.quit()));
|
|
130
|
+
this.available.length = 0;
|
|
131
|
+
// Zamknij wypożyczone połączenia (mogą mieć blocking BRPOP) — disconnect przerywa natychmiast
|
|
132
|
+
for (const conn of this.borrowed) {
|
|
133
|
+
conn.disconnect();
|
|
134
|
+
}
|
|
135
|
+
this.borrowed.clear();
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Konfiguruje handlery eventów dla połączenia
|
|
140
|
+
*/
|
|
141
|
+
setupEventHandlers(connection, name) {
|
|
142
|
+
const logger = this.options.logger;
|
|
143
|
+
connection.on('error', (error) => {
|
|
144
|
+
logger.error(`Błąd połączenia Redis (${name})`, {
|
|
145
|
+
connectionName: name,
|
|
146
|
+
error: (0, redis_error_formatter_1.formatRedisError)(error),
|
|
147
|
+
errorCode: (0, redis_error_formatter_1.getErrorCode)(error),
|
|
148
|
+
timestamp: new Date().toISOString(),
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.default = RpcConnectionPool;
|
|
154
|
+
//# sourceMappingURL=rpc-connection-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-connection-pool.js","sourceRoot":"","sources":["../../../src/shared/redis/rpc-connection-pool.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qCAAmD;AAEnD,mEAAyE;AAczE;;;;;;;;;;;GAWG;AACH,MAAqB,iBAAiB;IAWpC,YAA6B,OAAiC;QAAjC,YAAO,GAAP,OAAO,CAA0B;QAV7C,cAAS,GAAY,EAAE,CAAC;QACjC,WAAM,GAAG,CAAC,CAAC;QACF,YAAO,GAGnB,EAAE,CAAC;QACR,gEAAgE;QAC/C,aAAQ,GAAG,IAAI,GAAG,EAAS,CAAC;QACrC,WAAM,GAAG,KAAK,CAAC;QAGrB,IAAI,OAAO,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE;YAClD,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACU,OAAO;;YAClB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,MAAM,IAA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CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YACvD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YAE1B,8FAA8F;YAC9F,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACjC,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;KAAA;IAED;;OAEG;IACK,kBAAkB,CAAC,UAAiB,EAAE,IAAY;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QAEnC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;YACtC,MAAM,CAAC,KAAK,CAAC,0BAA0B,IAAI,GAAG,EAAE;gBAC9C,cAAc,EAAE,IAAI;gBACpB,KAAK,EAAE,IAAA,wCAAgB,EAAC,KAAK,CAAC;gBAC9B,SAAS,EAAE,IAAA,oCAAY,EAAC,KAAK,CAAC;gBAC9B,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjJD,oCAiJC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const rpc_connection_pool_1 = __importDefault(require("./rpc-connection-pool"));
|
|
16
|
+
// Mock ioredis
|
|
17
|
+
jest.mock('ioredis', () => {
|
|
18
|
+
const mockRedis = jest.fn().mockImplementation(() => ({
|
|
19
|
+
on: jest.fn(),
|
|
20
|
+
quit: jest.fn().mockResolvedValue('OK'),
|
|
21
|
+
disconnect: jest.fn(),
|
|
22
|
+
status: 'ready',
|
|
23
|
+
}));
|
|
24
|
+
return { Redis: mockRedis };
|
|
25
|
+
});
|
|
26
|
+
const createMockLogger = () => ({
|
|
27
|
+
log: jest.fn(),
|
|
28
|
+
error: jest.fn(),
|
|
29
|
+
warn: jest.fn(),
|
|
30
|
+
debug: jest.fn(),
|
|
31
|
+
});
|
|
32
|
+
describe('RpcConnectionPool', () => {
|
|
33
|
+
let logger;
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
logger = createMockLogger();
|
|
36
|
+
jest.clearAllMocks();
|
|
37
|
+
});
|
|
38
|
+
describe('konstruktor', () => {
|
|
39
|
+
it('powinien utworzyć pustą pulę z limitem', () => {
|
|
40
|
+
const pool = new rpc_connection_pool_1.default({
|
|
41
|
+
maxSize: 10,
|
|
42
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
43
|
+
logger,
|
|
44
|
+
});
|
|
45
|
+
expect(pool.activeCount).toBe(0);
|
|
46
|
+
expect(pool.waitingCount).toBe(0);
|
|
47
|
+
});
|
|
48
|
+
it('powinien rzucić błąd gdy maxSize < 1', () => {
|
|
49
|
+
expect(() => new rpc_connection_pool_1.default({
|
|
50
|
+
maxSize: 0,
|
|
51
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
52
|
+
logger,
|
|
53
|
+
})).toThrow('Maksymalny rozmiar puli RPC musi wynosić co najmniej 1');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('acquire/release', () => {
|
|
57
|
+
it('powinien utworzyć nowe połączenie przy acquire()', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const pool = new rpc_connection_pool_1.default({
|
|
59
|
+
maxSize: 5,
|
|
60
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
61
|
+
logger,
|
|
62
|
+
});
|
|
63
|
+
const conn = yield pool.acquire();
|
|
64
|
+
expect(conn).toBeDefined();
|
|
65
|
+
expect(pool.activeCount).toBe(1);
|
|
66
|
+
}));
|
|
67
|
+
it('powinien reużywać połączenie po release()', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
const pool = new rpc_connection_pool_1.default({
|
|
69
|
+
maxSize: 5,
|
|
70
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
71
|
+
logger,
|
|
72
|
+
});
|
|
73
|
+
const conn1 = yield pool.acquire();
|
|
74
|
+
pool.release(conn1);
|
|
75
|
+
expect(pool.activeCount).toBe(0);
|
|
76
|
+
const conn2 = yield pool.acquire();
|
|
77
|
+
expect(conn2).toBe(conn1); // Ten sam obiekt — reuse
|
|
78
|
+
expect(pool.activeCount).toBe(1);
|
|
79
|
+
}));
|
|
80
|
+
it('powinien kolejkować gdy limit osiągnięty', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
const pool = new rpc_connection_pool_1.default({
|
|
82
|
+
maxSize: 1,
|
|
83
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
84
|
+
logger,
|
|
85
|
+
});
|
|
86
|
+
const conn1 = yield pool.acquire();
|
|
87
|
+
expect(pool.activeCount).toBe(1);
|
|
88
|
+
// Drugie acquire powinno czekać
|
|
89
|
+
let conn2Resolved = false;
|
|
90
|
+
const conn2Promise = pool.acquire().then((c) => {
|
|
91
|
+
conn2Resolved = true;
|
|
92
|
+
return c;
|
|
93
|
+
});
|
|
94
|
+
// Jeszcze nie resolved
|
|
95
|
+
yield new Promise((r) => setTimeout(r, 10));
|
|
96
|
+
expect(conn2Resolved).toBe(false);
|
|
97
|
+
expect(pool.waitingCount).toBe(1);
|
|
98
|
+
// Release — drugie acquire powinno się rozwiązać
|
|
99
|
+
pool.release(conn1);
|
|
100
|
+
const conn2 = yield conn2Promise;
|
|
101
|
+
expect(conn2Resolved).toBe(true);
|
|
102
|
+
expect(conn2).toBe(conn1); // Ten sam obiekt — przekazany bezpośrednio
|
|
103
|
+
expect(pool.waitingCount).toBe(0);
|
|
104
|
+
}));
|
|
105
|
+
it('powinien rzucić błąd na acquire po zamknięciu', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
+
const pool = new rpc_connection_pool_1.default({
|
|
107
|
+
maxSize: 5,
|
|
108
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
109
|
+
logger,
|
|
110
|
+
});
|
|
111
|
+
yield pool.close();
|
|
112
|
+
yield expect(pool.acquire()).rejects.toThrow('Pula połączeń RPC jest zamknięta');
|
|
113
|
+
}));
|
|
114
|
+
});
|
|
115
|
+
describe('close()', () => {
|
|
116
|
+
it('powinien zamknąć dostępne połączenia', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
const pool = new rpc_connection_pool_1.default({
|
|
118
|
+
maxSize: 5,
|
|
119
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
120
|
+
logger,
|
|
121
|
+
});
|
|
122
|
+
const conn = yield pool.acquire();
|
|
123
|
+
pool.release(conn);
|
|
124
|
+
yield pool.close();
|
|
125
|
+
// Idempotentność
|
|
126
|
+
yield pool.close();
|
|
127
|
+
}));
|
|
128
|
+
it('powinien odrzucić czekających przy zamknięciu puli', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
+
const pool = new rpc_connection_pool_1.default({
|
|
130
|
+
maxSize: 1,
|
|
131
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
132
|
+
logger,
|
|
133
|
+
});
|
|
134
|
+
// Zajmij jedyne połączenie
|
|
135
|
+
yield pool.acquire();
|
|
136
|
+
// Kolejny acquire czeka na wolne połączenie
|
|
137
|
+
const waitingPromise = pool.acquire();
|
|
138
|
+
// Zamknij pulę — czekający powinien dostać reject
|
|
139
|
+
yield pool.close();
|
|
140
|
+
yield expect(waitingPromise).rejects.toThrow('Pula połączeń RPC została zamknięta');
|
|
141
|
+
}));
|
|
142
|
+
it('powinien zamknąć aktywne (wypożyczone) połączenia przy close()', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
|
+
const pool = new rpc_connection_pool_1.default({
|
|
144
|
+
maxSize: 5,
|
|
145
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
146
|
+
logger,
|
|
147
|
+
});
|
|
148
|
+
// Wypożycz 2 połączenia — symuluje aktywne BRPOP
|
|
149
|
+
const conn1 = yield pool.acquire();
|
|
150
|
+
const conn2 = yield pool.acquire();
|
|
151
|
+
expect(pool.activeCount).toBe(2);
|
|
152
|
+
// Zamknij pulę — powinien disconnect wypożyczone połączenia
|
|
153
|
+
yield pool.close();
|
|
154
|
+
expect(conn1.disconnect).toHaveBeenCalled();
|
|
155
|
+
expect(conn2.disconnect).toHaveBeenCalled();
|
|
156
|
+
}));
|
|
157
|
+
it('powinien zamknąć połączenie zwrócone po close()', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
158
|
+
const pool = new rpc_connection_pool_1.default({
|
|
159
|
+
maxSize: 5,
|
|
160
|
+
redisOptions: { host: 'localhost', port: 6379 },
|
|
161
|
+
logger,
|
|
162
|
+
});
|
|
163
|
+
const conn = yield pool.acquire();
|
|
164
|
+
// Zamknij pulę z aktywnym połączeniem
|
|
165
|
+
yield pool.close();
|
|
166
|
+
// Teraz caller zwraca połączenie — powinno być disconnect zamiast push do available
|
|
167
|
+
pool.release(conn);
|
|
168
|
+
// Połączenie powinno mieć disconnect (raz z close, raz z release po close)
|
|
169
|
+
expect(conn.disconnect).toHaveBeenCalledTimes(2);
|
|
170
|
+
}));
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
//# sourceMappingURL=rpc-connection-pool.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-connection-pool.spec.js","sourceRoot":"","sources":["../../../src/shared/redis/rpc-connection-pool.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gFAAsD;AAGtD,eAAe;AACf,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACxB,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;QACpD,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;QACb,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC;QACvC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,MAAM,EAAE,OAAO;KAChB,CAAC,CAAC,CAAC;IACJ,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,GAAY,EAAE,CAAC,CAAC;IACvC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;IAChB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;IACf,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;CACjB,CAAC,CAAC;AAEH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAI,MAAe,CAAC;IAEpB,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,GAAG,gBAAgB,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;QAC3B,EAAE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YAEjC,4DAA4D;YAC5D,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YAEnB,MAAM,CAAE,KAA8C,CAAC,UAAU,CAAC,CAAC,gBAAgB,EAAE,CAAC;YACtF,MAAM,CAAE,KAA8C,CAAC,UAAU,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACxF,CAAC,CAAA,CAAC,CAAC;QAEH,EAAE,CAAC,iDAAiD,EAAE,GAAS,EAAE;YAC/D,MAAM,IAAI,GAAG,IAAI,6BAAiB,CAAC;gBACjC,OAAO,EAAE,CAAC;gBACV,YAAY,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE;gBAC/C,MAAM;aACP,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YAElC,sCAAsC;YACtC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YAEnB,oFAAoF;YACpF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEnB,2EAA2E;YAC3E,MAAM,CAAE,IAA6C,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC7F,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Współdzielone typy dla EventBus i CommandBus
|
|
3
3
|
*/
|
|
4
|
-
/**
|
|
5
|
-
* Typ dla funkcji synchronicznych
|
|
6
|
-
*/
|
|
7
|
-
export type TCallable<TArgs extends unknown[] = unknown[], TReturn = unknown> = (...args: TArgs) => TReturn;
|
|
8
4
|
/**
|
|
9
5
|
* Typ dla funkcji asynchronicznych
|
|
10
6
|
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bezpieczne pobranie komunikatu błędu z nieznanego typu
|
|
3
|
+
* Eliminuje zduplikowany wzorzec: error instanceof Error ? error.message : String(error)
|
|
4
|
+
*
|
|
5
|
+
* @param error - Nieznany typ błędu
|
|
6
|
+
* @returns Komunikat błędu jako string
|
|
7
|
+
*/
|
|
8
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getErrorMessage = getErrorMessage;
|
|
4
|
+
/**
|
|
5
|
+
* Bezpieczne pobranie komunikatu błędu z nieznanego typu
|
|
6
|
+
* Eliminuje zduplikowany wzorzec: error instanceof Error ? error.message : String(error)
|
|
7
|
+
*
|
|
8
|
+
* @param error - Nieznany typ błędu
|
|
9
|
+
* @returns Komunikat błędu jako string
|
|
10
|
+
*/
|
|
11
|
+
function getErrorMessage(error) {
|
|
12
|
+
return error instanceof Error ? error.message : String(error);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=error-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-utils.js","sourceRoot":"","sources":["../../../src/shared/utils/error-utils.ts"],"names":[],"mappings":";;AAOA,0CAEC;AATD;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pp-command-bus",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Distributed Command Bus library
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Distributed Command Bus library with Redis Streams transport, MessagePack serialization, and RPC via LPUSH/BRPOP for DragonflyDB",
|
|
5
5
|
"homepage": "https://gitlab.polskiepolisy.pl/lib/pp-command-bus",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
"semantic-release": "semantic-release",
|
|
25
25
|
"semantic-release:dry-run": "semantic-release --dry-run",
|
|
26
26
|
"demo:rpc": "node ./dist/examples/rpc.demo.js",
|
|
27
|
-
"demo:rpc-throughput": "node ./dist/examples/rpc-throughput.demo.js"
|
|
28
|
-
"demo:rpc-compression": "node ./dist/examples/rpc-compression.demo.js"
|
|
27
|
+
"demo:rpc-throughput": "node ./dist/examples/rpc-throughput.demo.js"
|
|
29
28
|
},
|
|
30
29
|
"keywords": [
|
|
31
30
|
"command-bus",
|
|
32
31
|
"cqrs",
|
|
33
32
|
"rpc",
|
|
34
|
-
"
|
|
33
|
+
"redis-streams",
|
|
35
34
|
"dragonfly",
|
|
36
35
|
"redis",
|
|
37
36
|
"distributed",
|
|
38
37
|
"typescript",
|
|
39
|
-
"
|
|
38
|
+
"msgpack",
|
|
39
|
+
"ioredis"
|
|
40
40
|
],
|
|
41
41
|
"files": [
|
|
42
42
|
"dist",
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
]
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@commitlint/cli": "^20.1
|
|
73
|
-
"@commitlint/config-conventional": "^20.
|
|
72
|
+
"@commitlint/cli": "^20.4.1",
|
|
73
|
+
"@commitlint/config-conventional": "^20.4.1",
|
|
74
74
|
"@semantic-release/changelog": "^6.0.3",
|
|
75
75
|
"@semantic-release/git": "^10.0.1",
|
|
76
|
-
"@semantic-release/gitlab": "^13.
|
|
76
|
+
"@semantic-release/gitlab": "^13.3.0",
|
|
77
77
|
"@types/jest": "^30.0.0",
|
|
78
78
|
"@types/node": "^24.6.1",
|
|
79
79
|
"@typescript-eslint/eslint-plugin": "^8.45.0",
|
|
@@ -83,13 +83,13 @@
|
|
|
83
83
|
"husky": "^9.1.7",
|
|
84
84
|
"jest": "^30.2.0",
|
|
85
85
|
"prettier": "^3.6.2",
|
|
86
|
-
"semantic-release": "^
|
|
86
|
+
"semantic-release": "^25.0.3",
|
|
87
87
|
"ts-jest": "^29.4.5",
|
|
88
88
|
"ts-node": "^10.9.2",
|
|
89
89
|
"typescript": "^5.9.3"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"
|
|
93
|
-
"ioredis": "^5.
|
|
92
|
+
"@msgpack/msgpack": "^3.1.3",
|
|
93
|
+
"ioredis": "^5.9.2"
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Informacje o systemie
|
|
3
|
-
*/
|
|
4
|
-
export interface SystemInfo {
|
|
5
|
-
/**
|
|
6
|
-
* Liczba dostępnych CPU (cores)
|
|
7
|
-
*/
|
|
8
|
-
cpuCount: number;
|
|
9
|
-
/**
|
|
10
|
-
* Całkowita pamięć RAM w GB
|
|
11
|
-
*/
|
|
12
|
-
totalMemoryGB: number;
|
|
13
|
-
/**
|
|
14
|
-
* Dostępna pamięć RAM w GB
|
|
15
|
-
*/
|
|
16
|
-
freeMemoryGB: number;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Auto-optymalizator konfiguracji CommandBus
|
|
20
|
-
* Wykrywa zasoby systemowe i oblicza optymalne ustawienia concurrency
|
|
21
|
-
*/
|
|
22
|
-
export default class AutoConfigOptimizer {
|
|
23
|
-
/**
|
|
24
|
-
* Oblicza optymalny concurrency na podstawie zasobów systemowych
|
|
25
|
-
* Używa heurystyki zakładającej I/O-heavy workload (Redis/BullMQ)
|
|
26
|
-
*
|
|
27
|
-
* @returns Rekomendowany concurrency
|
|
28
|
-
*/
|
|
29
|
-
static calculateOptimalConcurrency(): number;
|
|
30
|
-
/**
|
|
31
|
-
* Zwraca informacje o systemie
|
|
32
|
-
* @returns Informacje systemowe
|
|
33
|
-
*/
|
|
34
|
-
static getSystemInfo(): SystemInfo;
|
|
35
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const os_1 = require("os");
|
|
4
|
-
/**
|
|
5
|
-
* Auto-optymalizator konfiguracji CommandBus
|
|
6
|
-
* Wykrywa zasoby systemowe i oblicza optymalne ustawienia concurrency
|
|
7
|
-
*/
|
|
8
|
-
class AutoConfigOptimizer {
|
|
9
|
-
/**
|
|
10
|
-
* Oblicza optymalny concurrency na podstawie zasobów systemowych
|
|
11
|
-
* Używa heurystyki zakładającej I/O-heavy workload (Redis/BullMQ)
|
|
12
|
-
*
|
|
13
|
-
* @returns Rekomendowany concurrency
|
|
14
|
-
*/
|
|
15
|
-
static calculateOptimalConcurrency() {
|
|
16
|
-
const systemInfo = AutoConfigOptimizer.getSystemInfo();
|
|
17
|
-
const { cpuCount, freeMemoryGB } = systemInfo;
|
|
18
|
-
// Bazowy concurrency dla I/O-heavy workload (Redis/BullMQ)
|
|
19
|
-
// Worker spędza większość czasu czekając na Redis, więc możemy mieć więcej workerów niż CPU
|
|
20
|
-
let baseConcurrency = cpuCount * 50;
|
|
21
|
-
// Korekta dla dostępnej pamięci RAM
|
|
22
|
-
if (freeMemoryGB < 2) {
|
|
23
|
-
// Bardzo mało RAM (<2GB) - agresywnie zmniejsz
|
|
24
|
-
baseConcurrency *= 0.3;
|
|
25
|
-
}
|
|
26
|
-
else if (freeMemoryGB < 4) {
|
|
27
|
-
// Mało RAM (<4GB) - zmniejsz
|
|
28
|
-
baseConcurrency *= 0.5;
|
|
29
|
-
}
|
|
30
|
-
else if (freeMemoryGB >= 16) {
|
|
31
|
-
// Dużo RAM (>=16GB) - zwiększ
|
|
32
|
-
baseConcurrency *= 1.2;
|
|
33
|
-
}
|
|
34
|
-
// Zapewnij sensowne granice: min 10, max 2000
|
|
35
|
-
return Math.max(10, Math.min(2000, Math.round(baseConcurrency)));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Zwraca informacje o systemie
|
|
39
|
-
* @returns Informacje systemowe
|
|
40
|
-
*/
|
|
41
|
-
static getSystemInfo() {
|
|
42
|
-
const totalMemoryBytes = (0, os_1.totalmem)();
|
|
43
|
-
const freeMemoryBytes = (0, os_1.freemem)();
|
|
44
|
-
return {
|
|
45
|
-
cpuCount: (0, os_1.availableParallelism)(),
|
|
46
|
-
totalMemoryGB: Math.round((totalMemoryBytes / (1024 * 1024 * 1024)) * 10) / 10,
|
|
47
|
-
freeMemoryGB: Math.round((freeMemoryBytes / (1024 * 1024 * 1024)) * 10) / 10,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.default = AutoConfigOptimizer;
|
|
52
|
-
//# sourceMappingURL=auto-config-optimizer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-config-optimizer.js","sourceRoot":"","sources":["../../../src/command-bus/config/auto-config-optimizer.ts"],"names":[],"mappings":";;AAAA,2BAA6D;AAsB7D;;;GAGG;AACH,MAAqB,mBAAmB;IACtC;;;;;OAKG;IACI,MAAM,CAAC,2BAA2B;QACvC,MAAM,UAAU,GAAG,mBAAmB,CAAC,aAAa,EAAE,CAAC;QACvD,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC;QAE9C,2DAA2D;QAC3D,4FAA4F;QAC5F,IAAI,eAAe,GAAG,QAAQ,GAAG,EAAE,CAAC;QAEpC,oCAAoC;QACpC,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACrB,+CAA+C;YAC/C,eAAe,IAAI,GAAG,CAAC;QACzB,CAAC;aAAM,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YAC5B,6BAA6B;YAC7B,eAAe,IAAI,GAAG,CAAC;QACzB,CAAC;aAAM,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC;YAC9B,8BAA8B;YAC9B,eAAe,IAAI,GAAG,CAAC;QACzB,CAAC;QAED,8CAA8C;QAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,aAAa;QACzB,MAAM,gBAAgB,GAAG,IAAA,aAAQ,GAAE,CAAC;QACpC,MAAM,eAAe,GAAG,IAAA,YAAO,GAAE,CAAC;QAElC,OAAO;YACL,QAAQ,EAAE,IAAA,yBAAoB,GAAE;YAChC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,gBAAgB,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE;YAC9E,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,eAAe,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE;SAC7E,CAAC;IACJ,CAAC;CACF;AA7CD,sCA6CC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const auto_config_optimizer_1 = __importDefault(require("./auto-config-optimizer"));
|
|
7
|
-
describe('AutoConfigOptimizer', () => {
|
|
8
|
-
describe('calculateOptimalConcurrency', () => {
|
|
9
|
-
it('powinien zwrócić sensowną wartość concurrency', () => {
|
|
10
|
-
const concurrency = auto_config_optimizer_1.default.calculateOptimalConcurrency();
|
|
11
|
-
expect(concurrency).toBeGreaterThan(0);
|
|
12
|
-
// Sprawdź czy jest w sensownym zakresie
|
|
13
|
-
expect(concurrency).toBeGreaterThanOrEqual(10);
|
|
14
|
-
expect(concurrency).toBeLessThanOrEqual(2000);
|
|
15
|
-
});
|
|
16
|
-
it('powinien być wartością całkowitą', () => {
|
|
17
|
-
const concurrency = auto_config_optimizer_1.default.calculateOptimalConcurrency();
|
|
18
|
-
expect(Number.isInteger(concurrency)).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe('getSystemInfo', () => {
|
|
22
|
-
it('powinien zwrócić informacje o systemie', () => {
|
|
23
|
-
const systemInfo = auto_config_optimizer_1.default.getSystemInfo();
|
|
24
|
-
expect(systemInfo).toHaveProperty('cpuCount');
|
|
25
|
-
expect(systemInfo).toHaveProperty('totalMemoryGB');
|
|
26
|
-
expect(systemInfo).toHaveProperty('freeMemoryGB');
|
|
27
|
-
expect(systemInfo.cpuCount).toBeGreaterThan(0);
|
|
28
|
-
expect(systemInfo.totalMemoryGB).toBeGreaterThan(0);
|
|
29
|
-
expect(systemInfo.freeMemoryGB).toBeGreaterThan(0);
|
|
30
|
-
expect(systemInfo.freeMemoryGB).toBeLessThanOrEqual(systemInfo.totalMemoryGB);
|
|
31
|
-
});
|
|
32
|
-
it('powinien zaokrąglić wartości pamięci do 1 miejsca po przecinku', () => {
|
|
33
|
-
const systemInfo = auto_config_optimizer_1.default.getSystemInfo();
|
|
34
|
-
// Sprawdź czy wartości są zaokrąglone do 1 miejsca po przecinku
|
|
35
|
-
const totalDecimals = (systemInfo.totalMemoryGB.toString().split('.')[1] || '').length;
|
|
36
|
-
const freeDecimals = (systemInfo.freeMemoryGB.toString().split('.')[1] || '').length;
|
|
37
|
-
expect(totalDecimals).toBeLessThanOrEqual(1);
|
|
38
|
-
expect(freeDecimals).toBeLessThanOrEqual(1);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=auto-config-optimizer.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-config-optimizer.spec.js","sourceRoot":"","sources":["../../../src/command-bus/config/auto-config-optimizer.spec.ts"],"names":[],"mappings":";;;;;AAAA,oFAA0D;AAG1D,QAAQ,C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e,CAAC,CAAC,CAAC,CAAC;YACnD,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;YACxE,MAAM,UAAU,GAAG,+BAAmB,CAAC,aAAa,EAAE,CAAC;YAEvD,gEAAgE;YAChE,MAAM,aAAa,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;YACvF,MAAM,YAAY,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;YAErF,MAAM,CAAC,aAAa,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;YAC7C,MAAM,CAAC,YAAY,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.JobOptionsBuilder = exports.JobProcessor = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Moduł przetwarzania jobów BullMQ
|
|
9
|
-
* Eksportuje JobProcessor i JobOptionsBuilder
|
|
10
|
-
*/
|
|
11
|
-
var job_processor_1 = require("./job-processor");
|
|
12
|
-
Object.defineProperty(exports, "JobProcessor", { enumerable: true, get: function () { return __importDefault(job_processor_1).default; } });
|
|
13
|
-
var job_options_builder_1 = require("./job-options-builder");
|
|
14
|
-
Object.defineProperty(exports, "JobOptionsBuilder", { enumerable: true, get: function () { return __importDefault(job_options_builder_1).default; } });
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/command-bus/job/index.ts"],"names":[],"mappings":";;;;;;AAAA;;;GAGG;AACH,iDAA0D;AAAjD,8HAAA,OAAO,OAAgB;AAChC,6DAAqE;AAA5D,yIAAA,OAAO,OAAqB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type CommandBusConfig from '../config/command-bus-config';
|
|
2
|
-
import type { JobOptions } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* JobOptionsBuilder - buduje opcje dla jobów BullMQ
|
|
5
|
-
*
|
|
6
|
-
* Odpowiedzialność: Enkapsulacja konfiguracji job options zgodnie z SRP
|
|
7
|
-
*/
|
|
8
|
-
export default class JobOptionsBuilder {
|
|
9
|
-
private readonly config;
|
|
10
|
-
constructor(config: CommandBusConfig);
|
|
11
|
-
/**
|
|
12
|
-
* Buduje standardowe opcje dla jobów BullMQ
|
|
13
|
-
* @returns Opcje dla standardowych jobów komend
|
|
14
|
-
*/
|
|
15
|
-
buildStandardOptions(): JobOptions;
|
|
16
|
-
/**
|
|
17
|
-
* Buduje opcje dla RPC reply jobs
|
|
18
|
-
* @returns Opcje dla jobów odpowiedzi RPC (agresywniejsze czyszczenie)
|
|
19
|
-
*/
|
|
20
|
-
buildRpcReplyOptions(): JobOptions;
|
|
21
|
-
}
|