@onlineapps/infrastructure-tools 1.0.53 → 1.0.55
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 +4 -4
- package/package.json +3 -3
- package/src/health/healthPublisher.js +3 -3
- package/src/index.js +0 -4
- package/src/utils/logger.js +16 -14
package/README.md
CHANGED
|
@@ -99,10 +99,10 @@ await storage.putObject('workflow', 'path/to/file', buffer);
|
|
|
99
99
|
Waits for all infrastructure services to be reported as healthy by Registry.
|
|
100
100
|
|
|
101
101
|
**Options:**
|
|
102
|
-
- `redisUrl` (string): Redis URL
|
|
102
|
+
- `redisUrl` (string): Redis URL
|
|
103
103
|
- `maxWait` (number): Maximum wait time in ms (default: 300000 = 5 minutes)
|
|
104
104
|
- `checkInterval` (number): Check interval in ms (default: 5000 = 5 seconds)
|
|
105
|
-
- `logger` (Object):
|
|
105
|
+
- `logger` (Object|Function): **Required** logger instance (or function). No implicit console fallback.
|
|
106
106
|
|
|
107
107
|
**Returns:** `Promise<boolean>`
|
|
108
108
|
|
|
@@ -113,7 +113,7 @@ Initializes infrastructure queues with correct parameters from `queueConfig`.
|
|
|
113
113
|
**Options:**
|
|
114
114
|
- `queues` (Array<string>): Specific queues to create (default: all infrastructure queues)
|
|
115
115
|
- `connection` (Object): RabbitMQ connection (for channel recreation)
|
|
116
|
-
- `logger` (Object): Logger instance (
|
|
116
|
+
- `logger` (Object): Logger instance (required)
|
|
117
117
|
- `queueConfig` (Object): Queue config instance (default: from mq-client-core)
|
|
118
118
|
- `serviceName` (string): Used in queue mismatch alerts (default: `unknown-service`)
|
|
119
119
|
- `alertOnMismatch` (boolean): Disable automatic 406 alerts (default: `true`)
|
|
@@ -130,7 +130,7 @@ Creates a health publisher instance with custom publish function.
|
|
|
130
130
|
- `publishFunction` (Function): Function to publish message (required)
|
|
131
131
|
- `getHealthData` (Function): Function to get health data (required)
|
|
132
132
|
- `config` (Object): Configuration with `infrastructureHealth` settings
|
|
133
|
-
- `logger` (Object):
|
|
133
|
+
- `logger` (Object): **Required** logger instance (no implicit console fallback)
|
|
134
134
|
|
|
135
135
|
**Returns:** Health publisher instance with `start()`, `stop()`, `publishNow()` methods
|
|
136
136
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/infrastructure-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.55",
|
|
4
4
|
"description": "Infrastructure orchestration utilities for OA Drive infrastructure services (health tracking, queue initialization, service discovery)",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"author": "OnlineApps",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@onlineapps/mq-client-core": "1.0.
|
|
22
|
-
"@onlineapps/service-common": "1.0.
|
|
21
|
+
"@onlineapps/mq-client-core": "1.0.68",
|
|
22
|
+
"@onlineapps/service-common": "1.0.13",
|
|
23
23
|
"@onlineapps/storage-core": "1.0.12",
|
|
24
24
|
"uuid": "^9.0.1",
|
|
25
25
|
"@onlineapps/infra-logger": "^1.0.0"
|
|
@@ -39,9 +39,6 @@ function createHealthPublisher(options) {
|
|
|
39
39
|
logger: customLogger
|
|
40
40
|
} = options;
|
|
41
41
|
|
|
42
|
-
// Use shared logger utility for consistent logging
|
|
43
|
-
const logger = createLogger(customLogger);
|
|
44
|
-
|
|
45
42
|
if (!serviceName) {
|
|
46
43
|
throw new Error('serviceName is required');
|
|
47
44
|
}
|
|
@@ -52,6 +49,9 @@ function createHealthPublisher(options) {
|
|
|
52
49
|
throw new Error('getHealthData must be a function');
|
|
53
50
|
}
|
|
54
51
|
|
|
52
|
+
// Use shared logger utility for consistent logging (strict - no fallbacks).
|
|
53
|
+
const logger = createLogger(customLogger);
|
|
54
|
+
|
|
55
55
|
let healthCheckInterval = null;
|
|
56
56
|
let isPublishing = false;
|
|
57
57
|
|
package/src/index.js
CHANGED
|
@@ -50,13 +50,11 @@ const {
|
|
|
50
50
|
createBaseClientAdapter,
|
|
51
51
|
createAmqplibAdapter
|
|
52
52
|
} = require('./health/healthPublisher');
|
|
53
|
-
const { createLogger } = require('./utils/logger');
|
|
54
53
|
const { sendQueueMismatchAlert } = require('./monitoring/queueMismatchReporter');
|
|
55
54
|
|
|
56
55
|
module.exports = {
|
|
57
56
|
// MQ Client Core (re-exported for convenience)
|
|
58
57
|
BaseClient,
|
|
59
|
-
MQClient: BaseClient, // Alias for compatibility
|
|
60
58
|
queueConfig,
|
|
61
59
|
|
|
62
60
|
// Service Common utilities (re-exported - infrastructure services should use infrastructure-tools, not service-common directly)
|
|
@@ -90,8 +88,6 @@ module.exports = {
|
|
|
90
88
|
createAmqplibAdapter,
|
|
91
89
|
|
|
92
90
|
// Logger utilities
|
|
93
|
-
// createLogger - legacy logger wrapper (for backward compatibility)
|
|
94
|
-
createLogger,
|
|
95
91
|
// createInfraLogger - structured logging from @onlineapps/infra-logger (preferred)
|
|
96
92
|
createInfraLogger,
|
|
97
93
|
|
package/src/utils/logger.js
CHANGED
|
@@ -3,21 +3,27 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* logger.js
|
|
5
5
|
*
|
|
6
|
-
* Provides a
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Similar to conn-infra-mq logger utility for consistency across infrastructure libraries.
|
|
6
|
+
* Provides a strict logger normalization helper.
|
|
7
|
+
*
|
|
8
|
+
* NO FALLBACKS: callers must pass a logger explicitly. No implicit console fallback.
|
|
11
9
|
*/
|
|
12
10
|
|
|
13
11
|
function createLogger(customLogger) {
|
|
14
12
|
const methods = ['info', 'warn', 'error', 'debug'];
|
|
13
|
+
|
|
14
|
+
if (!customLogger) {
|
|
15
|
+
throw new Error('[infrastructure-tools][logger] Missing dependency - logger is required (no console fallback).');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Allow passing console directly
|
|
19
|
+
if (customLogger === console) {
|
|
20
|
+
return console;
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
if (
|
|
16
|
-
customLogger &&
|
|
17
24
|
typeof customLogger === 'object' &&
|
|
18
25
|
methods.every((fn) => typeof customLogger[fn] === 'function')
|
|
19
26
|
) {
|
|
20
|
-
// Wrap custom logger to ensure consistent signature
|
|
21
27
|
return {
|
|
22
28
|
info: (...args) => customLogger.info(...args),
|
|
23
29
|
warn: (...args) => customLogger.warn(...args),
|
|
@@ -26,13 +32,9 @@ function createLogger(customLogger) {
|
|
|
26
32
|
};
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
warn: (...args) => console.warn('[WARN]', ...args),
|
|
33
|
-
error: (...args) => console.error('[ERROR]', ...args),
|
|
34
|
-
debug: (...args) => console.debug('[DEBUG]', ...args),
|
|
35
|
-
};
|
|
35
|
+
throw new Error(
|
|
36
|
+
'[infrastructure-tools][logger] Invalid logger - Expected {info,warn,error,debug} functions (or console).'
|
|
37
|
+
);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
module.exports = {
|