@onlineapps/cookbook-router 1.0.11 → 1.0.13
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 -2
- package/src/router.js +29 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/cookbook-router",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Message routing for cookbook workflows - handles service discovery and queue routing",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "PROPRIETARY",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@onlineapps/conn-infra-mq": "1.1.57",
|
|
23
|
-
"@onlineapps/conn-orch-registry": "1.1.
|
|
23
|
+
"@onlineapps/conn-orch-registry": "1.1.34",
|
|
24
24
|
"@onlineapps/cookbook-core": "2.1.16"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
package/src/router.js
CHANGED
|
@@ -178,6 +178,35 @@ class CookbookRouter {
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Route message directly to a specific service
|
|
183
|
+
* @param {string} serviceName - Target service name
|
|
184
|
+
* @param {Object} message - Workflow message to send
|
|
185
|
+
* @returns {Promise<void>}
|
|
186
|
+
*/
|
|
187
|
+
async routeToService(serviceName, message) {
|
|
188
|
+
const { logger } = this.options;
|
|
189
|
+
|
|
190
|
+
if (!serviceName || typeof serviceName !== 'string') {
|
|
191
|
+
throw new Error('[CookbookRouter] routeToService - serviceName is required and must be a string');
|
|
192
|
+
}
|
|
193
|
+
if (!message || typeof message !== 'object') {
|
|
194
|
+
throw new Error('[CookbookRouter] routeToService - message is required and must be an object');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Verify service is available
|
|
198
|
+
const isAvailable = await this.serviceDiscovery.isServiceAvailable(serviceName);
|
|
199
|
+
if (!isAvailable) {
|
|
200
|
+
throw new Error(`[CookbookRouter] Service not available: ${serviceName}`);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Send to service workflow queue
|
|
204
|
+
const queueName = `${serviceName}.workflow`;
|
|
205
|
+
logger.info(`[CookbookRouter] Routing to service: ${queueName}`);
|
|
206
|
+
|
|
207
|
+
await this.queueManager.publish(queueName, message);
|
|
208
|
+
}
|
|
209
|
+
|
|
181
210
|
/**
|
|
182
211
|
* Handle retry logic for steps
|
|
183
212
|
* @param {Object} step - Step to retry
|