@versori/run 0.5.0-alpha.3 → 0.5.0-alpha.5
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/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/esm/src/connection/internal/FetchBuilder.js +19 -14
- package/esm/src/dsl/http/versori/webhookmiddleware.js +3 -3
- package/esm/src/internal/InternalAuth.d.ts.map +1 -1
- package/esm/src/internal/InternalAuth.js +0 -1
- package/esm/src/internal/supervisor.d.ts +6 -10
- package/esm/src/internal/supervisor.d.ts.map +1 -1
- package/esm/src/internal/supervisor.js +134 -46
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +1 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +17 -4
- package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/catch.js +2 -1
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +16 -5
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +6 -5
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/schedule.js +2 -2
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +5 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +1 -0
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +17 -4
- package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.js +2 -0
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +15 -5
- package/esm/src/interpreter/memory/compilers/http.js +5 -5
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +4 -3
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +11 -6
- package/esm/src/issues/Issues.d.ts.map +1 -1
- package/esm/src/issues/Issues.js +5 -0
- package/package.json +1 -1
- package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/script/src/connection/internal/FetchBuilder.js +19 -14
- package/script/src/dsl/http/versori/webhookmiddleware.js +3 -3
- package/script/src/internal/InternalAuth.d.ts.map +1 -1
- package/script/src/internal/InternalAuth.js +0 -1
- package/script/src/internal/supervisor.d.ts +6 -10
- package/script/src/internal/supervisor.d.ts.map +1 -1
- package/script/src/internal/supervisor.js +135 -47
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +1 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +16 -3
- package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/catch.js +2 -1
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +14 -3
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +5 -4
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/schedule.js +2 -2
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +5 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +1 -0
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +16 -3
- package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +2 -0
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +14 -4
- package/script/src/interpreter/memory/compilers/http.js +5 -5
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +4 -3
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +11 -6
- package/script/src/issues/Issues.d.ts.map +1 -1
- package/script/src/issues/Issues.js +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../../src/src/internal/supervisor.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../../src/src/internal/supervisor.ts"],"names":[],"mappings":"AAaA,OAAO,EACH,YAAY,EAIf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA2ClD,eAAO,MAAM,OAAO,SAEhB,CAAC;AA2BL,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA0DF,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAYjD;AAED,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BxF;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EACzC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,IAAI,EAAE,IAAI,GACX,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAwC5B;AAED,wBAAsB,cAAc,CAChC,IAAI,EAAE,WAAW,GAAG,GAAG,EACvB,GAAG,CAAC,EAAE,cAAc,EACpB,OAAO,CAAC,EAAE,WAAW,GACtB,OAAO,CAAC,QAAQ,CAAC,CAoCnB;AA0BD,qBAAa,IAAK,YAAW,YAAY;;IAOrC,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI;IAmBnF,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
|
@@ -13,19 +13,29 @@
|
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Fake = exports.enabled = void 0;
|
|
16
|
-
exports.
|
|
16
|
+
exports.signalReady = signalReady;
|
|
17
|
+
exports.registerWorkflow = registerWorkflow;
|
|
17
18
|
exports.sendTaskStartEvent = sendTaskStartEvent;
|
|
18
|
-
exports.registerCrons = registerCrons;
|
|
19
19
|
exports.mockAPIRequest = mockAPIRequest;
|
|
20
20
|
const core_1 = require("@opentelemetry/core");
|
|
21
21
|
const ConsoleLogger_js_1 = require("../observability/logging/ConsoleLogger.js");
|
|
22
|
-
const
|
|
22
|
+
const ChainTask_js_1 = require("../dsl/tasks/ChainTask.js");
|
|
23
|
+
const ScheduleTrigger_js_1 = require("../dsl/triggers/ScheduleTrigger.js");
|
|
24
|
+
const WebhookTrigger_js_1 = require("../dsl/triggers/WebhookTrigger.js");
|
|
25
|
+
const DurableTrigger_js_1 = require("../dsl/triggers/DurableTrigger.js");
|
|
26
|
+
const Task_js_1 = require("../dsl/Task.js");
|
|
27
|
+
const CatchTask_js_1 = require("../dsl/tasks/CatchTask.js");
|
|
28
|
+
const FnTask_js_1 = require("../dsl/tasks/FnTask.js");
|
|
29
|
+
const HttpTask_js_1 = require("../dsl/tasks/HttpTask.js");
|
|
30
|
+
const BackgroundTask_js_1 = require("../dsl/tasks/BackgroundTask.js");
|
|
31
|
+
const ParallelTask_js_1 = require("../dsl/tasks/ParallelTask.js");
|
|
32
|
+
const supervisorURL = (function () {
|
|
23
33
|
return Deno.env.get('RUN_SUPERVISOR_URL') || '';
|
|
24
|
-
}();
|
|
25
|
-
exports.enabled = function () {
|
|
34
|
+
})();
|
|
35
|
+
exports.enabled = (function () {
|
|
26
36
|
return Deno.env.get('RUN_SUPERVISOR_URL') ? true : false;
|
|
27
|
-
}();
|
|
28
|
-
const flows = function () {
|
|
37
|
+
})();
|
|
38
|
+
const flows = (function () {
|
|
29
39
|
try {
|
|
30
40
|
const _cwd = Deno.cwd();
|
|
31
41
|
const flowsFile = Deno.readTextFileSync(_cwd + '/versori-flow.json');
|
|
@@ -33,8 +43,9 @@ const flows = function () {
|
|
|
33
43
|
const nodes = {};
|
|
34
44
|
for (const node of flows.nodes) {
|
|
35
45
|
nodes[node.id] = {
|
|
36
|
-
description: node
|
|
37
|
-
steps: node
|
|
46
|
+
description: node?.data?.description,
|
|
47
|
+
steps: node?.data?.steps,
|
|
48
|
+
files: node?.data?.files[0],
|
|
38
49
|
};
|
|
39
50
|
}
|
|
40
51
|
return nodes;
|
|
@@ -42,64 +53,140 @@ const flows = function () {
|
|
|
42
53
|
catch {
|
|
43
54
|
return {};
|
|
44
55
|
}
|
|
45
|
-
}();
|
|
56
|
+
})();
|
|
46
57
|
const logger = new ConsoleLogger_js_1.ConsoleLogger('debug');
|
|
47
|
-
|
|
58
|
+
function getTriggerData(workflow) {
|
|
59
|
+
if (workflow.trigger instanceof WebhookTrigger_js_1.WebhookTrigger) {
|
|
60
|
+
return {
|
|
61
|
+
id: workflow.trigger.id,
|
|
62
|
+
type: 'webhook',
|
|
63
|
+
method: workflow.trigger.options.method || 'post',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else if (workflow.trigger instanceof ScheduleTrigger_js_1.ScheduleTrigger) {
|
|
67
|
+
return {
|
|
68
|
+
id: workflow.trigger.id,
|
|
69
|
+
type: 'schedule',
|
|
70
|
+
schedule: workflow.trigger.schedule,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else if (workflow.trigger instanceof DurableTrigger_js_1.DurableWorkflowTrigger) {
|
|
74
|
+
return {
|
|
75
|
+
id: workflow.trigger.id,
|
|
76
|
+
type: 'durable',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
function getTaskData(task) {
|
|
82
|
+
let taskData = [];
|
|
83
|
+
if (task instanceof ChainTask_js_1.ChainTask) {
|
|
84
|
+
taskData = task.tasks.map((t) => getTaskData(t)).flat();
|
|
85
|
+
}
|
|
86
|
+
else if (task instanceof CatchTask_js_1.CatchTask) {
|
|
87
|
+
taskData = [...getTaskData(task._base), ...getTaskData(task._errorHandler)];
|
|
88
|
+
}
|
|
89
|
+
else if (task instanceof BackgroundTask_js_1.BackgroundTask) {
|
|
90
|
+
taskData = getTaskData(task._base);
|
|
91
|
+
}
|
|
92
|
+
else if (task instanceof ParallelTask_js_1.ParallelTask) {
|
|
93
|
+
// I'm not sure if this is correct, but I don't think there are any ParallelTasks out in the wild yet
|
|
94
|
+
taskData = [...getTaskData(task._base), ...getTaskData(task._each)];
|
|
95
|
+
}
|
|
96
|
+
else if (task instanceof FnTask_js_1.FnTask) {
|
|
97
|
+
taskData.push({
|
|
98
|
+
taskId: task.id,
|
|
99
|
+
type: task[Task_js_1.TaskType].toLowerCase(),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else if (task instanceof HttpTask_js_1.HttpTaskImpl) {
|
|
103
|
+
taskData.push({
|
|
104
|
+
taskId: task.id,
|
|
105
|
+
type: task[Task_js_1.TaskType].toLowerCase(),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// yolo
|
|
110
|
+
taskData.push({
|
|
111
|
+
taskId: String(task.id || 'unknown'),
|
|
112
|
+
type: task[Task_js_1.TaskType].toLowerCase(),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return taskData;
|
|
116
|
+
}
|
|
117
|
+
async function signalReady() {
|
|
48
118
|
if (!exports.enabled) {
|
|
49
119
|
return;
|
|
50
120
|
}
|
|
51
121
|
try {
|
|
52
|
-
await fetch(`${supervisorURL}/
|
|
53
|
-
method:
|
|
54
|
-
body: JSON.stringify(Object.fromEntries(webhooks)),
|
|
55
|
-
headers: {
|
|
56
|
-
"Content-Type": "application/json",
|
|
57
|
-
},
|
|
122
|
+
await fetch(`${supervisorURL}/ready`, {
|
|
123
|
+
method: 'POST',
|
|
58
124
|
});
|
|
59
125
|
}
|
|
60
126
|
catch (err) {
|
|
61
|
-
logger.error('Failed to
|
|
127
|
+
logger.error('Failed to signal ready to supervisor', { error: err });
|
|
62
128
|
}
|
|
63
129
|
}
|
|
64
|
-
async function
|
|
130
|
+
async function registerWorkflow(workflow) {
|
|
65
131
|
if (!exports.enabled) {
|
|
66
132
|
return;
|
|
67
133
|
}
|
|
134
|
+
const triggerData = getTriggerData(workflow);
|
|
135
|
+
const tasks = getTaskData(workflow.task);
|
|
136
|
+
try {
|
|
137
|
+
if (triggerData) {
|
|
138
|
+
const data = {
|
|
139
|
+
workflowId: triggerData.id,
|
|
140
|
+
trigger: triggerData,
|
|
141
|
+
tasks,
|
|
142
|
+
};
|
|
143
|
+
await fetch(`${supervisorURL}/register-workflow`, {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
body: JSON.stringify(data),
|
|
146
|
+
headers: {
|
|
147
|
+
'Content-Type': 'application/json',
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
logger.error('Failed to register workflow with supervisor', { error: err });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async function sendTaskStartEvent(taskId, ctx, span) {
|
|
157
|
+
if (!exports.enabled) {
|
|
158
|
+
return ctx;
|
|
159
|
+
}
|
|
68
160
|
const data = {
|
|
69
161
|
taskId,
|
|
70
162
|
spanId: span.spanContext().spanId,
|
|
71
163
|
traceId: span.spanContext().traceId,
|
|
72
164
|
startTime: new Date().toISOString(), // assuming current time as start time
|
|
165
|
+
executionId: ctx.executionId,
|
|
166
|
+
workflowId: ctx.workflowId || '',
|
|
73
167
|
};
|
|
74
168
|
try {
|
|
75
|
-
await fetch(`${supervisorURL}/tasks/start`, {
|
|
76
|
-
method:
|
|
169
|
+
const resp = await fetch(`${supervisorURL}/tasks/start`, {
|
|
170
|
+
method: 'POST',
|
|
77
171
|
body: JSON.stringify(data),
|
|
78
172
|
headers: {
|
|
79
|
-
|
|
173
|
+
'Content-Type': 'application/json',
|
|
80
174
|
},
|
|
81
175
|
});
|
|
176
|
+
if (resp.ok) {
|
|
177
|
+
const bodyString = await resp.text();
|
|
178
|
+
if (!bodyString) {
|
|
179
|
+
return ctx;
|
|
180
|
+
}
|
|
181
|
+
// TODO: XML, CSV yada yada
|
|
182
|
+
const respData = JSON.parse(bodyString);
|
|
183
|
+
return ctx.withData(respData);
|
|
184
|
+
}
|
|
82
185
|
}
|
|
83
186
|
catch (err) {
|
|
84
187
|
logger.error('Failed to send task start event to supervisor', { error: err });
|
|
85
188
|
}
|
|
86
|
-
|
|
87
|
-
async function registerCrons(crons) {
|
|
88
|
-
if (!exports.enabled) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
await fetch(`${supervisorURL}/register-schedulers`, {
|
|
93
|
-
method: "POST",
|
|
94
|
-
body: JSON.stringify(Object.fromEntries(crons)),
|
|
95
|
-
headers: {
|
|
96
|
-
"Content-Type": "application/json",
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
catch (err) {
|
|
101
|
-
logger.error('Failed to register crons with supervisor', { error: err });
|
|
102
|
-
}
|
|
189
|
+
return ctx;
|
|
103
190
|
}
|
|
104
191
|
async function mockAPIRequest(info, cnx, options) {
|
|
105
192
|
if (!exports.enabled) {
|
|
@@ -108,17 +195,17 @@ async function mockAPIRequest(info, cnx, options) {
|
|
|
108
195
|
const mockRequest = {
|
|
109
196
|
url: info.toString(),
|
|
110
197
|
payload: options?.body || '',
|
|
111
|
-
method: options?.method ||
|
|
198
|
+
method: options?.method || 'GET',
|
|
112
199
|
headers: options?.headers,
|
|
113
200
|
connection: cnx?.name,
|
|
114
201
|
connectionId: cnx?.id,
|
|
115
202
|
};
|
|
116
203
|
try {
|
|
117
204
|
const response = await fetch(`${supervisorURL}/ai/fake-fetch-call`, {
|
|
118
|
-
method:
|
|
205
|
+
method: 'POST',
|
|
119
206
|
body: JSON.stringify(mockRequest),
|
|
120
207
|
headers: {
|
|
121
|
-
|
|
208
|
+
'Content-Type': 'application/json',
|
|
122
209
|
},
|
|
123
210
|
});
|
|
124
211
|
if (!response.ok) {
|
|
@@ -146,10 +233,11 @@ function printableSpan(s) {
|
|
|
146
233
|
parentSpanContext: s.parentSpanContext,
|
|
147
234
|
spanContext: s.spanContext(),
|
|
148
235
|
};
|
|
149
|
-
const nodeDetail = flows[span.attributes['task.id']]; // I know I have coded all of those as string
|
|
236
|
+
const nodeDetail = flows[span.attributes['task.id']]; // I know I have coded all of those as string
|
|
150
237
|
if (nodeDetail) {
|
|
151
|
-
span.attributes['description'] = nodeDetail
|
|
152
|
-
span.attributes['steps'] = nodeDetail
|
|
238
|
+
span.attributes['description'] = nodeDetail?.description || '';
|
|
239
|
+
span.attributes['steps'] = nodeDetail?.steps || '';
|
|
240
|
+
span.attributes['files'] = nodeDetail?.files || '';
|
|
153
241
|
}
|
|
154
242
|
return span;
|
|
155
243
|
}
|
|
@@ -163,10 +251,10 @@ class Fake {
|
|
|
163
251
|
const ss = spans.map(printableSpan);
|
|
164
252
|
try {
|
|
165
253
|
fetch(`${supervisorURL}/receive-spans`, {
|
|
166
|
-
method:
|
|
254
|
+
method: 'POST',
|
|
167
255
|
body: JSON.stringify({ spans: ss }),
|
|
168
256
|
headers: {
|
|
169
|
-
|
|
257
|
+
'Content-Type': 'application/json',
|
|
170
258
|
},
|
|
171
259
|
}).catch((err) => {
|
|
172
260
|
logger.error('Failed to send spans to supervisor', { error: err });
|
|
@@ -95,6 +95,7 @@ export declare class DurableInterpreter {
|
|
|
95
95
|
private cronServer?;
|
|
96
96
|
private shutdownServer?;
|
|
97
97
|
private isShuttingDown;
|
|
98
|
+
private wfRegistration;
|
|
98
99
|
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, webhookRegistry: WebhookRegistry, platformApi: PlatformApi, cnxFetchFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issue: IssueAPI, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
|
|
99
100
|
static newInstance(options?: DurableInterpreterOptions): Promise<DurableInterpreter>;
|
|
100
101
|
register<O>(workflow: Workflow<O>, options?: DurableInterpreterOptions): Registration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DurableInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/DurableInterpreter.ts"],"names":[],"mappings":"AAYA,OAAsB,EAAQ,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AAEtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAuB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,CAAC,CAAa;IACpC,OAAO,CAAC,cAAc,CAAS;IAG/B,OAAO,CAAC,cAAc,CAAuB;gBAGxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAC3B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,eAAe,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,uBAAuB,EACxC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,YAAY,EACvB,aAAa,EAAE,QAAQ,EACvB,OAAO,CAAC,EAAE,OAAO,YAAA;WAWzB,WAAW,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgH9F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAyDhE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmO5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CASxB"}
|
|
@@ -189,6 +189,13 @@ class DurableInterpreter {
|
|
|
189
189
|
writable: true,
|
|
190
190
|
value: false
|
|
191
191
|
});
|
|
192
|
+
// Workflow registration promises only used when supervisor is enabled
|
|
193
|
+
Object.defineProperty(this, "wfRegistration", {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
configurable: true,
|
|
196
|
+
writable: true,
|
|
197
|
+
value: []
|
|
198
|
+
});
|
|
192
199
|
if (typeof this.log === 'undefined') {
|
|
193
200
|
// this captures the old way of instantiating the DurableInterpreter and provides an
|
|
194
201
|
// error message back to the user to let them know they should use the new way.
|
|
@@ -292,6 +299,9 @@ class DurableInterpreter {
|
|
|
292
299
|
},
|
|
293
300
|
};
|
|
294
301
|
this.registeredWorkflows.push(registration);
|
|
302
|
+
if (supervisor_js_1.enabled) {
|
|
303
|
+
this.wfRegistration.push((0, supervisor_js_1.registerWorkflow)(workflow));
|
|
304
|
+
}
|
|
295
305
|
return registration;
|
|
296
306
|
}
|
|
297
307
|
async start() {
|
|
@@ -324,6 +334,7 @@ class DurableInterpreter {
|
|
|
324
334
|
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
325
335
|
span.setAttribute('execution.id', ctx.executionId);
|
|
326
336
|
span.setAttribute('result', 'fail');
|
|
337
|
+
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
327
338
|
span.end();
|
|
328
339
|
});
|
|
329
340
|
try {
|
|
@@ -348,6 +359,7 @@ class DurableInterpreter {
|
|
|
348
359
|
this.tracer.startActiveSpan('done', (span) => {
|
|
349
360
|
span.setAttribute('execution.id', ctx.executionId);
|
|
350
361
|
span.setAttribute('result', 'pass');
|
|
362
|
+
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
351
363
|
span.end();
|
|
352
364
|
});
|
|
353
365
|
try {
|
|
@@ -397,9 +409,6 @@ class DurableInterpreter {
|
|
|
397
409
|
});
|
|
398
410
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
399
411
|
}
|
|
400
|
-
// register with supervisor
|
|
401
|
-
await (0, supervisor_js_1.registerCrons)(this.cronRegistry);
|
|
402
|
-
await (0, supervisor_js_1.registerWebhooks)(this.webhookRegistry);
|
|
403
412
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
404
413
|
this.log.info(`Express server listening on port ${port}`);
|
|
405
414
|
});
|
|
@@ -436,6 +445,10 @@ class DurableInterpreter {
|
|
|
436
445
|
}
|
|
437
446
|
};
|
|
438
447
|
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
448
|
+
if (supervisor_js_1.enabled) {
|
|
449
|
+
await Promise.all(this.wfRegistration);
|
|
450
|
+
await (0, supervisor_js_1.signalReady)();
|
|
451
|
+
}
|
|
439
452
|
return new Promise((resolve) => {
|
|
440
453
|
let serversClosed = 0;
|
|
441
454
|
const totalServers = [this.webhookServer, this.cronServer].filter(Boolean).length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAuFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -27,6 +27,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
27
27
|
span.setAttribute('task.type', 'catch');
|
|
28
28
|
span.setAttribute('type', 'task');
|
|
29
29
|
if (error instanceof Error) {
|
|
30
|
+
span.setAttribute('status', 'fail');
|
|
30
31
|
span.recordException(error);
|
|
31
32
|
span.setAttribute('error.message', error.message);
|
|
32
33
|
span.setAttribute('error.stack', error.stack ?? '');
|
|
@@ -64,7 +65,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
64
65
|
reason: 'error',
|
|
65
66
|
severity: 'low',
|
|
66
67
|
});
|
|
67
|
-
span.setAttribute('
|
|
68
|
+
span.setAttribute('status', 'fail');
|
|
68
69
|
span.end();
|
|
69
70
|
return errorOperator((0, rxjs_1.of)(ctx.withData(new ExecutionError_js_1.ExecutionError(ctx, `${error}`, { cause: error }))));
|
|
70
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAoDnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -17,14 +17,14 @@ const rxjs_1 = require("rxjs");
|
|
|
17
17
|
const FnTask_js_1 = require("../../../dsl/tasks/FnTask.js");
|
|
18
18
|
const supervisor_js_1 = require("../../../internal/supervisor.js");
|
|
19
19
|
function compileFn(compilerCtx, task) {
|
|
20
|
-
return (src) => src.pipe((0, rxjs_1.
|
|
21
|
-
complete: () => compilerCtx.log.debug('fn.complete'),
|
|
22
|
-
}), (0, rxjs_1.mergeMap)(async (ctx) => {
|
|
20
|
+
return (src) => src.pipe((0, rxjs_1.mergeMap)(async (ctx) => {
|
|
23
21
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
22
|
+
await (0, supervisor_js_1.sendTaskStartEvent)(task.id, ctx, span);
|
|
24
23
|
span.setAttribute('task.id', task.id);
|
|
25
24
|
span.setAttribute('type', 'task');
|
|
26
25
|
span.setAttribute('task.type', 'fn');
|
|
27
26
|
span.setAttribute('execution.id', ctx.executionId);
|
|
27
|
+
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
28
28
|
try {
|
|
29
29
|
const spanContext = span.spanContext();
|
|
30
30
|
const ctxWithLogger = ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
@@ -38,8 +38,19 @@ function compileFn(compilerCtx, task) {
|
|
|
38
38
|
if (supervisor_js_1.enabled) {
|
|
39
39
|
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
40
40
|
}
|
|
41
|
+
span.setAttribute('status', 'pass');
|
|
41
42
|
return result;
|
|
42
43
|
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error instanceof Error) {
|
|
46
|
+
span.setAttribute('status', 'fail');
|
|
47
|
+
span.recordException(error);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
span.recordException(new Error(String(error)));
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
43
54
|
finally {
|
|
44
55
|
span.end();
|
|
45
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAyHnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.httpCompiler = void 0;
|
|
16
16
|
const rxjs_1 = require("rxjs");
|
|
17
|
-
const operators_1 = require("rxjs/operators");
|
|
18
17
|
const DynamicFetchFactory_js_1 = require("../../../connection/DynamicFetchFactory.js");
|
|
19
18
|
const FetchBuilder_js_1 = require("../../../connection/internal/FetchBuilder.js");
|
|
20
19
|
const StaticFetchFactory_js_1 = require("../../../connection/StaticFetchFactory.js");
|
|
@@ -72,25 +71,27 @@ function compileHttp(compilerCtx, task) {
|
|
|
72
71
|
const result = await task.fn(httpContext);
|
|
73
72
|
return ctx.withData(result);
|
|
74
73
|
}
|
|
75
|
-
return (src) => src.pipe((0,
|
|
76
|
-
complete: () => compilerCtx.log.debug('http.complete'),
|
|
77
|
-
}), (0, rxjs_1.mergeMap)((ctx) => {
|
|
74
|
+
return (src) => src.pipe((0, rxjs_1.mergeMap)((ctx) => {
|
|
78
75
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
76
|
+
await (0, supervisor_js_1.sendTaskStartEvent)(task.id, ctx, span);
|
|
79
77
|
span.setAttribute('task.id', task.id);
|
|
80
78
|
span.setAttribute('task.type', 'http');
|
|
81
79
|
span.setAttribute('type', 'task');
|
|
82
80
|
span.setAttribute('execution.id', ctx.executionId);
|
|
83
81
|
span.setAttribute('connection.name', task.opts.connection);
|
|
82
|
+
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
84
83
|
const spanContext = span.spanContext();
|
|
85
84
|
try {
|
|
86
85
|
const result = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
|
|
87
86
|
if (supervisor_js_1.enabled) {
|
|
88
87
|
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
89
88
|
}
|
|
89
|
+
span.setAttribute('status', 'pass');
|
|
90
90
|
return result;
|
|
91
91
|
}
|
|
92
92
|
catch (error) {
|
|
93
93
|
if (error instanceof Error) {
|
|
94
|
+
span.setAttribute('status', 'fail');
|
|
94
95
|
span.recordException(error);
|
|
95
96
|
}
|
|
96
97
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAqJ7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -55,7 +55,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
55
55
|
});
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
const executionCtx = ctx.contextProvider.create(activation[0], {});
|
|
58
|
+
const executionCtx = ctx.contextProvider.create(activation[0], {}, { workflowId: trigger.id });
|
|
59
59
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
60
60
|
try {
|
|
61
61
|
subscriber.next(executionCtx);
|
|
@@ -87,7 +87,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
activations.forEach((activation) => {
|
|
90
|
-
const executionCtx = ctx.contextProvider.create(activation, {});
|
|
90
|
+
const executionCtx = ctx.contextProvider.create(activation, {}, { workflowId: trigger.id });
|
|
91
91
|
try {
|
|
92
92
|
subscriber.next(executionCtx);
|
|
93
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA2TxE,CAAC"}
|
|
@@ -90,6 +90,7 @@ exports.webhookCompiler = {
|
|
|
90
90
|
onError = trigger.options.response.onError;
|
|
91
91
|
}
|
|
92
92
|
const ctxOptionsFn = (req, res) => ({
|
|
93
|
+
workflowId: trigger.id,
|
|
93
94
|
onSuccess: (ctx) => {
|
|
94
95
|
if (isSync) {
|
|
95
96
|
sendResponse(res, onSuccess(ctx));
|
|
@@ -114,8 +115,10 @@ exports.webhookCompiler = {
|
|
|
114
115
|
if (!ctx.webhookRouter) {
|
|
115
116
|
throw new Error('Router not available in compiler context');
|
|
116
117
|
}
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
ctx.log.info('webhook endpoint added', {
|
|
119
|
+
id: trigger.id,
|
|
120
|
+
method,
|
|
121
|
+
});
|
|
119
122
|
if (corsOptions) {
|
|
120
123
|
if (typeof corsOptions === 'boolean') {
|
|
121
124
|
ctx.webhookRouter.use((0, cors_1.default)());
|
|
@@ -88,6 +88,7 @@ export declare class MemoryInterpreter {
|
|
|
88
88
|
private cronServer?;
|
|
89
89
|
private shutdownServer?;
|
|
90
90
|
private isShuttingDown;
|
|
91
|
+
private wfRegistration;
|
|
91
92
|
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, webhookRegistry: WebhookRegistry, cnxFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issuesProvider: IssueAPI, cfgReader: ConfigReader, otelSDK?: NodeSDK | undefined);
|
|
92
93
|
static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
|
|
93
94
|
register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAQ,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AAEtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGrE,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAc/D,OAAO,EAAE,QAAQ,EAAa,MAAM,wBAAwB,CAAC;AAK7D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAmB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAE9B;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,MA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AAC,eAAe;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAtB7B,OAAO,CAAC,mBAAmB,CAA2B;IACtD,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,cAAc,CAAC,CAAa;IACpC,OAAO,CAAC,cAAc,CAAS;IAG/B,OAAO,CAAC,cAAc,CAAuB;gBAGxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAC3B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,eAAe,EAAE,eAAe,EACvB,UAAU,EAAE,uBAAuB,EACnC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,QAAQ,EACxB,SAAS,EAAE,YAAY,EACvB,OAAO,CAAC,EAAE,OAAO,YAAA;WAWzB,WAAW,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA8G5F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAwD/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAuN5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CASxB"}
|
|
@@ -173,6 +173,13 @@ class MemoryInterpreter {
|
|
|
173
173
|
writable: true,
|
|
174
174
|
value: false
|
|
175
175
|
});
|
|
176
|
+
// Workflow registration promises only used when supervisor is enabled
|
|
177
|
+
Object.defineProperty(this, "wfRegistration", {
|
|
178
|
+
enumerable: true,
|
|
179
|
+
configurable: true,
|
|
180
|
+
writable: true,
|
|
181
|
+
value: []
|
|
182
|
+
});
|
|
176
183
|
if (typeof this.log === 'undefined') {
|
|
177
184
|
// this captures the old way of instantiating the MemoryInterpreter and provides an
|
|
178
185
|
// error message back to the user to let them know they should use the new way.
|
|
@@ -272,6 +279,9 @@ class MemoryInterpreter {
|
|
|
272
279
|
},
|
|
273
280
|
};
|
|
274
281
|
this.registeredWorkflows.push(registration);
|
|
282
|
+
if (supervisor_js_1.enabled) {
|
|
283
|
+
this.wfRegistration.push((0, supervisor_js_1.registerWorkflow)(workflow));
|
|
284
|
+
}
|
|
275
285
|
return registration;
|
|
276
286
|
}
|
|
277
287
|
async start() {
|
|
@@ -304,6 +314,7 @@ class MemoryInterpreter {
|
|
|
304
314
|
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
305
315
|
span.setAttribute('execution.id', ctx.executionId);
|
|
306
316
|
span.setAttribute('result', 'fail');
|
|
317
|
+
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
307
318
|
span.end();
|
|
308
319
|
});
|
|
309
320
|
try {
|
|
@@ -328,6 +339,7 @@ class MemoryInterpreter {
|
|
|
328
339
|
this.tracer.startActiveSpan('done', (span) => {
|
|
329
340
|
span.setAttribute('execution.id', ctx.executionId);
|
|
330
341
|
span.setAttribute('result', 'pass');
|
|
342
|
+
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
331
343
|
span.end();
|
|
332
344
|
});
|
|
333
345
|
try {
|
|
@@ -366,9 +378,6 @@ class MemoryInterpreter {
|
|
|
366
378
|
});
|
|
367
379
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
368
380
|
}
|
|
369
|
-
// register with suopervisor
|
|
370
|
-
await (0, supervisor_js_1.registerCrons)(this.cronRegistry);
|
|
371
|
-
await (0, supervisor_js_1.registerWebhooks)(this.webhookRegistry);
|
|
372
381
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
373
382
|
this.log.info(`Express server listening on port ${port}`);
|
|
374
383
|
});
|
|
@@ -405,6 +414,10 @@ class MemoryInterpreter {
|
|
|
405
414
|
}
|
|
406
415
|
};
|
|
407
416
|
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
417
|
+
if (supervisor_js_1.enabled) {
|
|
418
|
+
await Promise.all(this.wfRegistration);
|
|
419
|
+
await (0, supervisor_js_1.signalReady)();
|
|
420
|
+
}
|
|
408
421
|
return new Promise((resolve) => {
|
|
409
422
|
let serversClosed = 0;
|
|
410
423
|
const totalServers = [this.webhookServer, this.cronServer].filter(Boolean).length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA0FnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -28,6 +28,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
28
28
|
span.setAttribute('task.type', 'catch');
|
|
29
29
|
span.setAttribute('type', 'task');
|
|
30
30
|
if (error instanceof Error) {
|
|
31
|
+
span.setAttribute('status', 'fail');
|
|
31
32
|
span.recordException(error);
|
|
32
33
|
span.setAttribute('error.message', error.message);
|
|
33
34
|
span.setAttribute('error.stack', error.stack ?? '');
|
|
@@ -65,6 +66,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
65
66
|
ctx.log.error('execution has encountered an error', {
|
|
66
67
|
error: error,
|
|
67
68
|
});
|
|
69
|
+
span.setAttribute('status', 'fail');
|
|
68
70
|
span.setAttribute('error', `${error}`);
|
|
69
71
|
span.end();
|
|
70
72
|
return errorOperator((0, rxjs_1.of)(ctx.withData(new ExecutionError_js_1.ExecutionError(ctx, `${error}`, { cause: error }))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAoDnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|