@onlineapps/conn-orch-orchestrator 1.0.2 → 1.0.3
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
CHANGED
|
@@ -70,6 +70,14 @@ class WorkflowOrchestrator {
|
|
|
70
70
|
// Validate cookbook structure
|
|
71
71
|
this.cookbook.validateCookbook(cookbookDef);
|
|
72
72
|
|
|
73
|
+
// Ensure delivery configuration is preserved in context (required by Delivery Dispatcher)
|
|
74
|
+
// Delivery comes from cookbook.delivery (set by Gateway) and must be passed through to workflow.completed
|
|
75
|
+
const enrichedContext = {
|
|
76
|
+
...context,
|
|
77
|
+
// Preserve delivery from cookbook if not already in context
|
|
78
|
+
delivery: context?.delivery || cookbookDef?.delivery || { handler: 'none' }
|
|
79
|
+
};
|
|
80
|
+
|
|
73
81
|
// Find current step
|
|
74
82
|
const step = cookbookDef.steps.find(s => s.id === current_step);
|
|
75
83
|
if (!step) {
|
|
@@ -83,29 +91,52 @@ class WorkflowOrchestrator {
|
|
|
83
91
|
return { skipped: true, reason: 'wrong_service' };
|
|
84
92
|
}
|
|
85
93
|
|
|
94
|
+
// Publish workflow.progress to monitoring.workflow using unified helper
|
|
95
|
+
const { publishToMonitoringWorkflow } = require('@onlineapps/mq-client-core').monitoring;
|
|
96
|
+
try {
|
|
97
|
+
const stepIndex = cookbookDef.steps.findIndex(s => s.id === current_step);
|
|
98
|
+
await publishToMonitoringWorkflow(this.mqClient, {
|
|
99
|
+
event_type: 'progress',
|
|
100
|
+
workflow_id: workflow_id,
|
|
101
|
+
service_name: serviceName,
|
|
102
|
+
step_index: stepIndex >= 0 ? stepIndex : 0,
|
|
103
|
+
step_id: current_step,
|
|
104
|
+
cookbook: cookbookDef,
|
|
105
|
+
context: enrichedContext,
|
|
106
|
+
status: 'in_progress',
|
|
107
|
+
timestamp: new Date().toISOString()
|
|
108
|
+
}, this.logger, { workflow_id, step_id: current_step });
|
|
109
|
+
} catch (monitoringError) {
|
|
110
|
+
// Don't fail workflow if monitoring publish fails (helper already logs)
|
|
111
|
+
this.logger.warn('Failed to publish workflow.progress to monitoring', {
|
|
112
|
+
workflow_id,
|
|
113
|
+
error: monitoringError.message
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
86
117
|
// Check cache if available
|
|
87
118
|
let result;
|
|
88
119
|
if (this.cache && step.type === 'task') {
|
|
89
|
-
const cacheKey = this._getCacheKey(step,
|
|
120
|
+
const cacheKey = this._getCacheKey(step, enrichedContext);
|
|
90
121
|
result = await this.cache.get(cacheKey);
|
|
91
122
|
|
|
92
123
|
if (result) {
|
|
93
124
|
this.logger.info('Cache hit', { step: step.id, cacheKey });
|
|
94
125
|
} else {
|
|
95
126
|
// Execute the step
|
|
96
|
-
result = await this._executeStep(step,
|
|
127
|
+
result = await this._executeStep(step, enrichedContext, cookbookDef);
|
|
97
128
|
await this.cache.set(cacheKey, result, { ttl: 300 });
|
|
98
129
|
}
|
|
99
130
|
} else {
|
|
100
131
|
// Execute without cache
|
|
101
|
-
result = await this._executeStep(step,
|
|
132
|
+
result = await this._executeStep(step, enrichedContext, cookbookDef);
|
|
102
133
|
}
|
|
103
134
|
|
|
104
|
-
// Update context with result
|
|
135
|
+
// Update context with result (preserve delivery from enrichedContext)
|
|
105
136
|
const updatedContext = {
|
|
106
|
-
...
|
|
137
|
+
...enrichedContext,
|
|
107
138
|
steps: {
|
|
108
|
-
...
|
|
139
|
+
...enrichedContext.steps,
|
|
109
140
|
[current_step]: result
|
|
110
141
|
}
|
|
111
142
|
};
|
|
@@ -13,8 +13,9 @@ const CookbookConnector = require('@onlineapps/conn-orch-cookbook');
|
|
|
13
13
|
|
|
14
14
|
// Skip integration tests if external services are not available
|
|
15
15
|
const SKIP_INTEGRATION = process.env.SKIP_INTEGRATION === 'true';
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const { requireEnv } = require('../../../../../tests/_helpers/test-config');
|
|
17
|
+
const RABBITMQ_URL = requireEnv('RABBITMQ_URL', 'RabbitMQ connection URL');
|
|
18
|
+
const REGISTRY_URL = requireEnv('REGISTRY_URL', 'Registry service URL');
|
|
18
19
|
|
|
19
20
|
describe('Orchestrator - Integration Tests @integration', () => {
|
|
20
21
|
if (SKIP_INTEGRATION) {
|