@onlineapps/conn-base-hub 1.0.6 → 1.0.7
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/coverage/clover.xml +86 -53
- package/coverage/coverage-final.json +3 -1
- package/coverage/lcov-report/config.js.html +217 -0
- package/coverage/lcov-report/defaults.js.html +169 -0
- package/coverage/lcov-report/index.html +49 -19
- package/coverage/lcov-report/index.js.html +175 -61
- package/coverage/lcov.info +203 -132
- package/logs/app.2025-12-21.log +0 -0
- package/package.json +2 -2
- package/src/config.js +44 -0
- package/src/defaults.js +28 -0
- package/src/index.js +53 -25
- package/tests/component/hub-integration.test.js +30 -28
- package/tests/unit/hub.test.js +47 -41
package/coverage/lcov.info
CHANGED
|
@@ -1,145 +1,216 @@
|
|
|
1
1
|
TN:
|
|
2
|
+
SF:src/config.js
|
|
3
|
+
FNF:0
|
|
4
|
+
FNH:0
|
|
5
|
+
DA:14,1
|
|
6
|
+
DA:15,1
|
|
7
|
+
DA:21,1
|
|
8
|
+
DA:43,1
|
|
9
|
+
LF:4
|
|
10
|
+
LH:4
|
|
11
|
+
BRF:0
|
|
12
|
+
BRH:0
|
|
13
|
+
end_of_record
|
|
14
|
+
TN:
|
|
15
|
+
SF:src/defaults.js
|
|
16
|
+
FNF:0
|
|
17
|
+
FNH:0
|
|
18
|
+
DA:16,1
|
|
19
|
+
LF:1
|
|
20
|
+
LH:1
|
|
21
|
+
BRF:0
|
|
22
|
+
BRH:0
|
|
23
|
+
end_of_record
|
|
24
|
+
TN:
|
|
2
25
|
SF:src/index.js
|
|
3
|
-
FN:
|
|
4
|
-
FN:
|
|
5
|
-
FN:
|
|
6
|
-
FN:
|
|
7
|
-
FN:
|
|
8
|
-
FN:
|
|
9
|
-
FN:
|
|
10
|
-
FN:
|
|
11
|
-
FN:
|
|
12
|
-
FN:
|
|
13
|
-
FN:
|
|
14
|
-
FN:
|
|
15
|
-
FN:
|
|
16
|
-
FN:
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
FN:35,(anonymous_0)
|
|
27
|
+
FN:37,(anonymous_1)
|
|
28
|
+
FN:44,(anonymous_2)
|
|
29
|
+
FN:51,(anonymous_3)
|
|
30
|
+
FN:52,(anonymous_4)
|
|
31
|
+
FN:53,(anonymous_5)
|
|
32
|
+
FN:54,(anonymous_6)
|
|
33
|
+
FN:55,(anonymous_7)
|
|
34
|
+
FN:94,(anonymous_8)
|
|
35
|
+
FN:142,(anonymous_9)
|
|
36
|
+
FN:167,(anonymous_10)
|
|
37
|
+
FN:181,(anonymous_11)
|
|
38
|
+
FN:194,(anonymous_12)
|
|
39
|
+
FN:204,(anonymous_13)
|
|
40
|
+
FN:212,(anonymous_14)
|
|
41
|
+
FN:223,(anonymous_15)
|
|
42
|
+
FN:242,(anonymous_16)
|
|
43
|
+
FN:280,(anonymous_17)
|
|
44
|
+
FN:289,(anonymous_18)
|
|
45
|
+
FNF:19
|
|
46
|
+
FNH:12
|
|
19
47
|
FNDA:1,(anonymous_0)
|
|
20
|
-
FNDA:
|
|
21
|
-
FNDA:
|
|
22
|
-
FNDA:
|
|
23
|
-
FNDA:
|
|
24
|
-
FNDA:
|
|
25
|
-
FNDA:
|
|
48
|
+
FNDA:3,(anonymous_1)
|
|
49
|
+
FNDA:7,(anonymous_2)
|
|
50
|
+
FNDA:0,(anonymous_3)
|
|
51
|
+
FNDA:0,(anonymous_4)
|
|
52
|
+
FNDA:0,(anonymous_5)
|
|
53
|
+
FNDA:0,(anonymous_6)
|
|
26
54
|
FNDA:1,(anonymous_7)
|
|
27
|
-
FNDA:
|
|
28
|
-
FNDA:
|
|
55
|
+
FNDA:3,(anonymous_8)
|
|
56
|
+
FNDA:1,(anonymous_9)
|
|
29
57
|
FNDA:1,(anonymous_10)
|
|
30
58
|
FNDA:1,(anonymous_11)
|
|
31
|
-
FNDA:
|
|
32
|
-
FNDA:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
DA:
|
|
39
|
-
DA:
|
|
40
|
-
DA:
|
|
59
|
+
FNDA:2,(anonymous_12)
|
|
60
|
+
FNDA:2,(anonymous_13)
|
|
61
|
+
FNDA:1,(anonymous_14)
|
|
62
|
+
FNDA:1,(anonymous_15)
|
|
63
|
+
FNDA:0,(anonymous_16)
|
|
64
|
+
FNDA:0,(anonymous_17)
|
|
65
|
+
FNDA:0,(anonymous_18)
|
|
66
|
+
DA:15,1
|
|
67
|
+
DA:18,1
|
|
68
|
+
DA:36,1
|
|
69
|
+
DA:37,1
|
|
70
|
+
DA:39,3
|
|
71
|
+
DA:45,7
|
|
72
|
+
DA:49,7
|
|
73
|
+
DA:50,7
|
|
74
|
+
DA:51,0
|
|
75
|
+
DA:52,0
|
|
76
|
+
DA:53,0
|
|
77
|
+
DA:54,0
|
|
78
|
+
DA:56,1
|
|
79
|
+
DA:57,1
|
|
41
80
|
DA:62,7
|
|
42
|
-
DA:91,3
|
|
43
|
-
DA:94,3
|
|
44
81
|
DA:95,3
|
|
45
|
-
DA:98,
|
|
46
|
-
DA:99,
|
|
47
|
-
DA:
|
|
48
|
-
DA:
|
|
49
|
-
DA:
|
|
50
|
-
DA:
|
|
51
|
-
DA:
|
|
52
|
-
DA:
|
|
53
|
-
DA:
|
|
54
|
-
DA:
|
|
55
|
-
DA:
|
|
56
|
-
DA:
|
|
57
|
-
DA:
|
|
58
|
-
DA:
|
|
59
|
-
DA:
|
|
60
|
-
DA:
|
|
61
|
-
DA:
|
|
62
|
-
DA:
|
|
63
|
-
DA:
|
|
82
|
+
DA:98,3
|
|
83
|
+
DA:99,3
|
|
84
|
+
DA:104,3
|
|
85
|
+
DA:106,0
|
|
86
|
+
DA:109,0
|
|
87
|
+
DA:113,3
|
|
88
|
+
DA:114,3
|
|
89
|
+
DA:117,2
|
|
90
|
+
DA:118,0
|
|
91
|
+
DA:122,2
|
|
92
|
+
DA:123,2
|
|
93
|
+
DA:127,2
|
|
94
|
+
DA:128,2
|
|
95
|
+
DA:129,2
|
|
96
|
+
DA:133,2
|
|
97
|
+
DA:134,2
|
|
98
|
+
DA:135,2
|
|
99
|
+
DA:138,2
|
|
100
|
+
DA:143,1
|
|
101
|
+
DA:145,1
|
|
102
|
+
DA:146,1
|
|
64
103
|
DA:149,1
|
|
65
|
-
DA:
|
|
66
|
-
DA:
|
|
67
|
-
DA:
|
|
68
|
-
DA:
|
|
69
|
-
DA:
|
|
70
|
-
DA:
|
|
71
|
-
DA:
|
|
72
|
-
DA:
|
|
73
|
-
DA:
|
|
74
|
-
DA:
|
|
75
|
-
DA:
|
|
76
|
-
DA:
|
|
77
|
-
DA:
|
|
78
|
-
DA:
|
|
79
|
-
DA:
|
|
80
|
-
DA:
|
|
81
|
-
DA:
|
|
82
|
-
DA:
|
|
83
|
-
DA:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
BRDA:
|
|
103
|
-
BRDA:
|
|
104
|
-
BRDA:
|
|
105
|
-
BRDA:
|
|
106
|
-
BRDA:
|
|
107
|
-
BRDA:
|
|
108
|
-
BRDA:
|
|
109
|
-
BRDA:
|
|
110
|
-
BRDA:
|
|
111
|
-
BRDA:
|
|
112
|
-
BRDA:
|
|
113
|
-
BRDA:
|
|
114
|
-
BRDA:
|
|
115
|
-
BRDA:
|
|
116
|
-
BRDA:
|
|
117
|
-
BRDA:
|
|
118
|
-
BRDA:
|
|
119
|
-
BRDA:
|
|
120
|
-
BRDA:
|
|
121
|
-
BRDA:
|
|
122
|
-
BRDA:
|
|
123
|
-
BRDA:
|
|
104
|
+
DA:150,1
|
|
105
|
+
DA:153,1
|
|
106
|
+
DA:154,1
|
|
107
|
+
DA:157,1
|
|
108
|
+
DA:168,1
|
|
109
|
+
DA:182,1
|
|
110
|
+
DA:195,2
|
|
111
|
+
DA:196,1
|
|
112
|
+
DA:198,1
|
|
113
|
+
DA:205,2
|
|
114
|
+
DA:213,1
|
|
115
|
+
DA:224,1
|
|
116
|
+
DA:243,0
|
|
117
|
+
DA:246,0
|
|
118
|
+
DA:247,0
|
|
119
|
+
DA:248,0
|
|
120
|
+
DA:252,0
|
|
121
|
+
DA:255,0
|
|
122
|
+
DA:281,0
|
|
123
|
+
DA:283,0
|
|
124
|
+
DA:284,0
|
|
125
|
+
DA:288,0
|
|
126
|
+
DA:289,0
|
|
127
|
+
DA:290,0
|
|
128
|
+
DA:291,0
|
|
129
|
+
DA:292,0
|
|
130
|
+
DA:294,0
|
|
131
|
+
DA:298,0
|
|
132
|
+
DA:299,0
|
|
133
|
+
DA:300,0
|
|
134
|
+
DA:301,0
|
|
135
|
+
DA:302,0
|
|
136
|
+
DA:303,0
|
|
137
|
+
DA:306,0
|
|
138
|
+
DA:312,1
|
|
139
|
+
LF:73
|
|
140
|
+
LH:44
|
|
141
|
+
BRDA:51,0,0,0
|
|
142
|
+
BRDA:51,0,1,0
|
|
143
|
+
BRDA:52,1,0,0
|
|
144
|
+
BRDA:52,1,1,0
|
|
145
|
+
BRDA:53,2,0,0
|
|
146
|
+
BRDA:53,2,1,0
|
|
147
|
+
BRDA:54,3,0,0
|
|
148
|
+
BRDA:54,3,1,0
|
|
149
|
+
BRDA:56,4,0,1
|
|
150
|
+
BRDA:56,4,1,0
|
|
151
|
+
BRDA:56,5,0,1
|
|
152
|
+
BRDA:56,5,1,1
|
|
153
|
+
BRDA:65,6,0,5
|
|
154
|
+
BRDA:65,6,1,2
|
|
155
|
+
BRDA:67,7,0,5
|
|
156
|
+
BRDA:67,7,1,5
|
|
157
|
+
BRDA:67,7,2,0
|
|
158
|
+
BRDA:67,7,3,0
|
|
159
|
+
BRDA:69,8,0,5
|
|
160
|
+
BRDA:69,8,1,0
|
|
161
|
+
BRDA:74,9,0,4
|
|
162
|
+
BRDA:74,9,1,3
|
|
163
|
+
BRDA:77,10,0,4
|
|
164
|
+
BRDA:77,10,1,4
|
|
165
|
+
BRDA:77,10,2,0
|
|
166
|
+
BRDA:77,10,3,0
|
|
167
|
+
BRDA:83,11,0,3
|
|
168
|
+
BRDA:83,11,1,4
|
|
169
|
+
BRDA:113,12,0,3
|
|
170
|
+
BRDA:113,12,1,0
|
|
171
|
+
BRDA:117,13,0,0
|
|
172
|
+
BRDA:117,13,1,2
|
|
173
|
+
BRDA:127,14,0,2
|
|
174
|
+
BRDA:127,14,1,0
|
|
175
|
+
BRDA:133,15,0,2
|
|
176
|
+
BRDA:133,15,1,0
|
|
177
|
+
BRDA:145,16,0,1
|
|
178
|
+
BRDA:145,16,1,0
|
|
179
|
+
BRDA:149,17,0,1
|
|
180
|
+
BRDA:149,17,1,0
|
|
181
|
+
BRDA:153,18,0,1
|
|
182
|
+
BRDA:153,18,1,0
|
|
124
183
|
BRDA:153,19,0,1
|
|
125
|
-
BRDA:153,19,1,
|
|
126
|
-
BRDA:
|
|
127
|
-
BRDA:
|
|
128
|
-
BRDA:
|
|
129
|
-
BRDA:
|
|
130
|
-
BRDA:
|
|
131
|
-
BRDA:
|
|
132
|
-
BRDA:
|
|
133
|
-
BRDA:
|
|
134
|
-
BRDA:
|
|
135
|
-
BRDA:
|
|
136
|
-
BRDA:
|
|
137
|
-
BRDA:
|
|
138
|
-
BRDA:
|
|
139
|
-
BRDA:
|
|
140
|
-
BRDA:
|
|
184
|
+
BRDA:153,19,1,1
|
|
185
|
+
BRDA:171,20,0,1
|
|
186
|
+
BRDA:171,20,1,0
|
|
187
|
+
BRDA:172,21,0,1
|
|
188
|
+
BRDA:172,21,1,0
|
|
189
|
+
BRDA:195,22,0,1
|
|
190
|
+
BRDA:195,22,1,1
|
|
191
|
+
BRDA:205,23,0,2
|
|
192
|
+
BRDA:205,23,1,2
|
|
193
|
+
BRDA:205,23,2,1
|
|
194
|
+
BRDA:205,23,3,1
|
|
195
|
+
BRDA:215,24,0,1
|
|
196
|
+
BRDA:215,24,1,0
|
|
197
|
+
BRDA:243,25,0,0
|
|
198
|
+
BRDA:247,26,0,0
|
|
199
|
+
BRDA:247,26,1,0
|
|
141
200
|
BRDA:263,27,0,0
|
|
142
201
|
BRDA:263,27,1,0
|
|
143
|
-
|
|
144
|
-
|
|
202
|
+
BRDA:283,28,0,0
|
|
203
|
+
BRDA:283,28,1,0
|
|
204
|
+
BRDA:288,29,0,0
|
|
205
|
+
BRDA:288,29,1,0
|
|
206
|
+
BRDA:290,30,0,0
|
|
207
|
+
BRDA:290,30,1,0
|
|
208
|
+
BRDA:290,31,0,0
|
|
209
|
+
BRDA:290,31,1,0
|
|
210
|
+
BRDA:300,32,0,0
|
|
211
|
+
BRDA:300,32,1,0
|
|
212
|
+
BRDA:300,33,0,0
|
|
213
|
+
BRDA:300,33,1,0
|
|
214
|
+
BRF:73
|
|
215
|
+
BRH:32
|
|
145
216
|
end_of_record
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/conn-base-hub",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Central hub for OA Drive connectors - bundles and integrates all essential connector libraries",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@onlineapps/conn-infra-mq": "1.1.54",
|
|
27
27
|
"@onlineapps/conn-orch-cookbook": "2.0.12",
|
|
28
28
|
"@onlineapps/conn-orch-registry": "1.1.25",
|
|
29
|
-
"
|
|
29
|
+
"@onlineapps/runtime-config": "1.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"jest": "^29.7.0"
|
package/src/config.js
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Runtime configuration schema for @onlineapps/conn-base-hub.
|
|
5
|
+
*
|
|
6
|
+
* Uses @onlineapps/runtime-config for unified priority:
|
|
7
|
+
* 1. Explicit config
|
|
8
|
+
* 2. Environment variable (if applicable)
|
|
9
|
+
* 3. Owner defaults (from ./defaults.js)
|
|
10
|
+
*
|
|
11
|
+
* @module @onlineapps/conn-base-hub/config
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const { createRuntimeConfig } = require('@onlineapps/runtime-config');
|
|
15
|
+
const DEFAULTS = require('./defaults');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Runtime config schema for Hub
|
|
19
|
+
* Flat keys are used for simplicity (nested defaults are accessed via inline defaults)
|
|
20
|
+
*/
|
|
21
|
+
const runtimeCfg = createRuntimeConfig({
|
|
22
|
+
defaults: {},
|
|
23
|
+
schema: {
|
|
24
|
+
// Infrastructure topology (FAIL-FAST when used)
|
|
25
|
+
rabbitmqUrl: { env: 'RABBITMQ_URL', required: true },
|
|
26
|
+
|
|
27
|
+
minioEndpoint: { env: 'MINIO_ENDPOINT', required: true },
|
|
28
|
+
minioPort: { env: 'MINIO_PORT', required: true, type: 'number' },
|
|
29
|
+
minioAccessKey: { env: 'MINIO_ACCESS_KEY', required: true },
|
|
30
|
+
minioSecretKey: { env: 'MINIO_SECRET_KEY', required: true },
|
|
31
|
+
minioUseSSL: { env: 'MINIO_USE_SSL', default: false, type: 'boolean' },
|
|
32
|
+
|
|
33
|
+
// MQ defaults
|
|
34
|
+
mqType: { default: DEFAULTS.mq.type },
|
|
35
|
+
mqDefaultServiceQueueSuffix: { default: DEFAULTS.mq.defaultServiceQueueSuffix },
|
|
36
|
+
|
|
37
|
+
// Workflow defaults
|
|
38
|
+
workflowDefaultServiceQueueSuffix: { default: DEFAULTS.workflow.defaultServiceQueueSuffix },
|
|
39
|
+
workflowCompletedQueue: { default: DEFAULTS.workflow.completedQueue },
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
module.exports = runtimeCfg;
|
|
44
|
+
|
package/src/defaults.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Module-owned defaults for @onlineapps/conn-base-hub.
|
|
5
|
+
*
|
|
6
|
+
* Ownership rule:
|
|
7
|
+
* - Defaults that are specific to the "hub" (composition utilities, naming conventions)
|
|
8
|
+
* live here to avoid duplication across the module.
|
|
9
|
+
* - Callers can override behavior via explicit config (highest priority) or ENV (fallback).
|
|
10
|
+
*
|
|
11
|
+
* NOTE:
|
|
12
|
+
* - Infrastructure connection URLs should NOT be hardcoded here; those belong to their owning modules
|
|
13
|
+
* or must be provided explicitly via config/env.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
mq: {
|
|
18
|
+
type: 'rabbitmq',
|
|
19
|
+
defaultServiceQueueSuffix: '_queue',
|
|
20
|
+
},
|
|
21
|
+
workflow: {
|
|
22
|
+
defaultServiceQueueSuffix: '.queue',
|
|
23
|
+
completedQueue: 'workflow.completed',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
package/src/index.js
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* - Centralized logging
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// NOTE: dotenv.config() removed to avoid side effects in library code
|
|
14
|
+
// Consumers are responsible for loading their own .env
|
|
15
|
+
const runtimeCfg = require('./config');
|
|
14
16
|
|
|
15
17
|
// Re-export all connectors
|
|
16
18
|
module.exports = {
|
|
@@ -33,9 +35,8 @@ module.exports = {
|
|
|
33
35
|
createLogger: (() => {
|
|
34
36
|
const monitoring = require('@onlineapps/conn-base-monitoring');
|
|
35
37
|
return async function(config) {
|
|
36
|
-
// Initialize monitoring and return logger-like interface
|
|
37
|
-
|
|
38
|
-
return monitoring;
|
|
38
|
+
// Initialize monitoring and return logger-like interface (API returned by init)
|
|
39
|
+
return monitoring.init(config);
|
|
39
40
|
};
|
|
40
41
|
})(),
|
|
41
42
|
|
|
@@ -43,18 +44,27 @@ module.exports = {
|
|
|
43
44
|
createMicroservice: function(config) {
|
|
44
45
|
const { ServiceRegistryClient, MQClient, StorageConnector, createLogger } = module.exports;
|
|
45
46
|
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
// Logger instance is created lazily in init() to avoid side effects during construction.
|
|
48
|
+
// This also prevents unhandled promise rejections when env/config is incomplete in tests/dev.
|
|
49
|
+
let loggerApi = null;
|
|
50
|
+
const logger = {
|
|
51
|
+
info: (message, data) => (loggerApi ? loggerApi.info(message, data) : console.log(message, data)),
|
|
52
|
+
warn: (message, data) => (loggerApi ? loggerApi.warn(message, data) : console.warn(message, data)),
|
|
53
|
+
error: (message, data) => (loggerApi ? loggerApi.error(message, data) : console.error(message, data)),
|
|
54
|
+
debug: (message, data) => (loggerApi ? loggerApi.debug(message, data) : console.debug(message, data)),
|
|
55
|
+
close: async () => {
|
|
56
|
+
if (loggerApi && typeof loggerApi.shutdown === 'function') {
|
|
57
|
+
await loggerApi.shutdown();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
52
61
|
|
|
53
62
|
return {
|
|
54
63
|
logger,
|
|
55
64
|
// Initialize Registry Client
|
|
56
65
|
registry: config.registry ? new ServiceRegistryClient({
|
|
57
|
-
|
|
66
|
+
// Priority: explicit registry config → top-level config → ENV
|
|
67
|
+
amqpUrl: config.registry?.amqpUrl || config.registry?.url || config.amqpUrl || runtimeCfg.get('rabbitmqUrl'),
|
|
58
68
|
serviceName: config.serviceName,
|
|
59
69
|
version: config.version || '1.0.0',
|
|
60
70
|
...config.registry
|
|
@@ -62,18 +72,21 @@ module.exports = {
|
|
|
62
72
|
|
|
63
73
|
// Initialize MQ Client
|
|
64
74
|
mq: config.mq ? new MQClient({
|
|
65
|
-
type: '
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
type: runtimeCfg.get('mqType'),
|
|
76
|
+
// Priority: explicit mq config → top-level config → ENV
|
|
77
|
+
host: config.mq?.host || config.mq?.url || config.amqpUrl || runtimeCfg.get('rabbitmqUrl'),
|
|
78
|
+
queue: `${config.serviceName}${runtimeCfg.get('mqDefaultServiceQueueSuffix')}`,
|
|
68
79
|
...config.mq
|
|
69
80
|
}) : null,
|
|
70
81
|
|
|
71
82
|
// Initialize Storage (all MinIO config MUST come from env or config - no fallbacks)
|
|
72
83
|
storage: config.storage ? new StorageConnector({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
// Priority: explicit storage config → ENV (resolved via runtimeCfg)
|
|
85
|
+
endPoint: runtimeCfg.get('minioEndpoint', config.storage?.endPoint),
|
|
86
|
+
port: runtimeCfg.get('minioPort', config.storage?.port),
|
|
87
|
+
useSSL: runtimeCfg.get('minioUseSSL', config.storage?.useSSL),
|
|
88
|
+
accessKey: runtimeCfg.get('minioAccessKey', config.storage?.accessKey),
|
|
89
|
+
secretKey: runtimeCfg.get('minioSecretKey', config.storage?.secretKey),
|
|
77
90
|
...config.storage
|
|
78
91
|
}) : null,
|
|
79
92
|
|
|
@@ -81,6 +94,21 @@ module.exports = {
|
|
|
81
94
|
async init() {
|
|
82
95
|
const results = {};
|
|
83
96
|
|
|
97
|
+
// Initialize Logger (Monitoring) - optional, keep microservice usable even if monitoring can't start
|
|
98
|
+
try {
|
|
99
|
+
loggerApi = await createLogger({
|
|
100
|
+
serviceName: config.serviceName,
|
|
101
|
+
version: config.version,
|
|
102
|
+
...config.logger
|
|
103
|
+
});
|
|
104
|
+
results.logger = true;
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.warn(
|
|
107
|
+
`[conn-base-hub] Monitoring init failed - Continuing with console logger. Fix: set RABBITMQ_URL or pass logger.rabbitmq.url. (${err.message})`
|
|
108
|
+
);
|
|
109
|
+
results.logger = false;
|
|
110
|
+
}
|
|
111
|
+
|
|
84
112
|
// Initialize Registry
|
|
85
113
|
if (this.registry) {
|
|
86
114
|
await this.registry.initialize();
|
|
@@ -122,7 +150,7 @@ module.exports = {
|
|
|
122
150
|
promises.push(this.mq.disconnect());
|
|
123
151
|
}
|
|
124
152
|
|
|
125
|
-
if (this.logger && this.logger.close) {
|
|
153
|
+
if (this.logger && typeof this.logger.close === 'function') {
|
|
126
154
|
promises.push(this.logger.close());
|
|
127
155
|
}
|
|
128
156
|
|
|
@@ -167,7 +195,7 @@ module.exports = {
|
|
|
167
195
|
if (step.queue) {
|
|
168
196
|
return step.queue;
|
|
169
197
|
}
|
|
170
|
-
return `${step.service}.
|
|
198
|
+
return `${step.service}${runtimeCfg.get('workflowDefaultServiceQueueSuffix')}`;
|
|
171
199
|
},
|
|
172
200
|
|
|
173
201
|
/**
|
|
@@ -253,7 +281,7 @@ module.exports = {
|
|
|
253
281
|
const { current_step, cookbook } = message;
|
|
254
282
|
|
|
255
283
|
if (!cookbook?.steps) {
|
|
256
|
-
return
|
|
284
|
+
return runtimeCfg.get('workflowCompletedQueue');
|
|
257
285
|
}
|
|
258
286
|
|
|
259
287
|
// V2.1: steps is array, find current step by step_id
|
|
@@ -261,9 +289,9 @@ module.exports = {
|
|
|
261
289
|
const currentIndex = cookbook.steps.findIndex(s => s.step_id === current_step);
|
|
262
290
|
if (currentIndex >= 0 && currentIndex < cookbook.steps.length - 1) {
|
|
263
291
|
const nextStep = cookbook.steps[currentIndex + 1];
|
|
264
|
-
return `${nextStep.service}.
|
|
292
|
+
return `${nextStep.service}${runtimeCfg.get('workflowDefaultServiceQueueSuffix')}`;
|
|
265
293
|
}
|
|
266
|
-
return
|
|
294
|
+
return runtimeCfg.get('workflowCompletedQueue');
|
|
267
295
|
}
|
|
268
296
|
|
|
269
297
|
// V2.0 (deprecated): steps is object, current_step is step_id
|
|
@@ -272,10 +300,10 @@ module.exports = {
|
|
|
272
300
|
if (currentIndex >= 0 && currentIndex < stepIds.length - 1) {
|
|
273
301
|
const nextStepId = stepIds[currentIndex + 1];
|
|
274
302
|
const nextStep = cookbook.steps[nextStepId];
|
|
275
|
-
return `${nextStep.service}.
|
|
303
|
+
return `${nextStep.service}${runtimeCfg.get('workflowDefaultServiceQueueSuffix')}`;
|
|
276
304
|
}
|
|
277
305
|
|
|
278
|
-
return
|
|
306
|
+
return runtimeCfg.get('workflowCompletedQueue');
|
|
279
307
|
}
|
|
280
308
|
}
|
|
281
309
|
};
|