@onlineapps/mq-client-core 1.0.62 → 1.0.64
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/package.json +2 -3
- package/src/transports/rabbitmqClient.js +24 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/mq-client-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.64",
|
|
4
4
|
"description": "Core MQ client library for RabbitMQ - shared by infrastructure services and connectors",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
"amqplib": "^0.10.3",
|
|
22
22
|
"ajv": "^8.12.0",
|
|
23
23
|
"lodash.merge": "^4.6.2",
|
|
24
|
-
"@onlineapps/runtime-config": "1.0.
|
|
25
|
-
"@onlineapps/infrastructure-tools": "^1.0.23"
|
|
24
|
+
"@onlineapps/runtime-config": "1.0.2"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"jest": "^29.7.0"
|
|
@@ -19,21 +19,31 @@ const RecoveryWorker = require('../workers/RecoveryWorker');
|
|
|
19
19
|
const PublishMonitor = require('../monitoring/PublishMonitor');
|
|
20
20
|
const runtimeCfg = require('../config');
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Local structured logger (module-owned) to avoid dependency cycles.
|
|
24
|
+
*
|
|
25
|
+
* IMPORTANT:
|
|
26
|
+
* - mq-client-core is a low-level library used by infrastructure-tools.
|
|
27
|
+
* - Therefore mq-client-core MUST NOT depend on infrastructure-tools.
|
|
28
|
+
*/
|
|
29
|
+
function createInfraLogger(service, layer) {
|
|
30
|
+
const prefix = (contextId, action) => `[${contextId}:${service}:${layer}:${action}]`;
|
|
31
|
+
|
|
32
|
+
const toJson = (data) => {
|
|
27
33
|
try {
|
|
28
|
-
|
|
34
|
+
return JSON.stringify(data);
|
|
29
35
|
} catch (e) {
|
|
30
|
-
|
|
31
|
-
_createInfraLogger = (service, layer) => ({
|
|
32
|
-
log: (action, data) => console.log(`[${service}:${layer}:${action}]`, JSON.stringify(data))
|
|
33
|
-
});
|
|
36
|
+
return JSON.stringify({ error: 'failed_to_serialize', message: e.message });
|
|
34
37
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
input: (contextId, action, data) => console.log(prefix(contextId, action), toJson(data)),
|
|
42
|
+
output: (contextId, action, data) => console.log(prefix(contextId, action), toJson(data)),
|
|
43
|
+
process: (contextId, action, data) => console.log(prefix(contextId, action), toJson(data)),
|
|
44
|
+
lifecycle: (contextId, action, data) => console.log(prefix(contextId, action), toJson(data)),
|
|
45
|
+
fail: (contextId, action, data) => console.error(prefix(contextId, action), toJson(data)),
|
|
46
|
+
};
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
class RabbitMQClient extends EventEmitter {
|
|
@@ -119,8 +129,8 @@ class RabbitMQClient extends EventEmitter {
|
|
|
119
129
|
this._criticalHealthShutdownDelay = this._config.criticalHealthShutdownDelay || 60000; // Default: 60s delay before shutdown
|
|
120
130
|
this._criticalHealthStartTime = null; // Track when critical health started
|
|
121
131
|
|
|
122
|
-
// Create structured logger for infrastructure logging (
|
|
123
|
-
this._log =
|
|
132
|
+
// Create structured logger for infrastructure logging (module-owned)
|
|
133
|
+
this._log = createInfraLogger('mq-client-core', 'transport');
|
|
124
134
|
|
|
125
135
|
// Publish layer (retry + buffer)
|
|
126
136
|
this._publishLayer = new PublishLayer({
|