@versori/run 0.4.0-alpha.10 → 0.4.0-alpha.12
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/interpreter/durable/DurableInterpreter.js +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +8 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +1 -1
- package/package.json +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.js +8 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +1 -1
|
@@ -293,7 +293,7 @@ export class DurableInterpreter {
|
|
|
293
293
|
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
294
294
|
registration.subscription = registration.trigger$
|
|
295
295
|
.pipe(tap((ctx) => {
|
|
296
|
-
ctx.log.info('DurableInterpreter.executionStarted', {
|
|
296
|
+
ctx.log.info('DurableInterpreter.executionStarted', {});
|
|
297
297
|
}), mergeMap((ctx) => of(ctx).pipe(registration.task$, catchError((err) => {
|
|
298
298
|
ctx.log.error('DurableInterpreter.executionError', {
|
|
299
299
|
error: err instanceof Error ? err.toString() : err,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAuG9C;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAIhG,CAAC"}
|
|
@@ -23,6 +23,7 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
23
23
|
signal.addEventListener('abort', cleanup, { once: true });
|
|
24
24
|
let consecutiveErrors = 0;
|
|
25
25
|
const maxConsecutiveErrors = 5;
|
|
26
|
+
let currentlyRunningTasks = trigger.options.limit ?? 0;
|
|
26
27
|
(async () => {
|
|
27
28
|
while (true) {
|
|
28
29
|
if (signal.aborted) {
|
|
@@ -37,12 +38,13 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
37
38
|
break;
|
|
38
39
|
}
|
|
39
40
|
try {
|
|
41
|
+
const fetchLimit = (trigger.options.limit ?? 10) - currentlyRunningTasks;
|
|
40
42
|
// Right now the API itself will hang for a period of time if no workflows are available.
|
|
41
43
|
// so we don't need to add a delay here.
|
|
42
44
|
const wfs = await ctx.queueProvider.fetchWorkflows({
|
|
43
45
|
group: trigger.id,
|
|
44
46
|
ttl: trigger.options.ttl,
|
|
45
|
-
limit:
|
|
47
|
+
limit: fetchLimit,
|
|
46
48
|
});
|
|
47
49
|
if (!wfs) {
|
|
48
50
|
continue;
|
|
@@ -68,6 +70,7 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
68
70
|
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata.executionId ?? ulid().toString(), {
|
|
69
71
|
workflow: wf,
|
|
70
72
|
onSuccess: (completedContext) => {
|
|
73
|
+
currentlyRunningTasks--;
|
|
71
74
|
// locked status means we own the workflow and it's not completed yet
|
|
72
75
|
if (wf.status !== 'locked') {
|
|
73
76
|
return;
|
|
@@ -78,8 +81,12 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
78
81
|
status: 'completed',
|
|
79
82
|
});
|
|
80
83
|
},
|
|
84
|
+
onError: (_errorContext) => {
|
|
85
|
+
currentlyRunningTasks--;
|
|
86
|
+
},
|
|
81
87
|
});
|
|
82
88
|
consecutiveErrors = 0;
|
|
89
|
+
currentlyRunningTasks++;
|
|
83
90
|
subscriber.next(newContext);
|
|
84
91
|
}
|
|
85
92
|
}
|
|
@@ -273,7 +273,7 @@ export class MemoryInterpreter {
|
|
|
273
273
|
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
274
274
|
registration.subscription = registration.trigger$
|
|
275
275
|
.pipe(tap((ctx) => {
|
|
276
|
-
ctx.log.info('MemoryInterpreter.executionStarted', {
|
|
276
|
+
ctx.log.info('MemoryInterpreter.executionStarted', {});
|
|
277
277
|
}), mergeMap((ctx) => of(ctx).pipe(registration.task$, catchError((err) => {
|
|
278
278
|
ctx.log.error('MemoryInterpreter.executionError', {
|
|
279
279
|
error: err instanceof Error ? err.toString() : err,
|
package/package.json
CHANGED
|
@@ -299,7 +299,7 @@ class DurableInterpreter {
|
|
|
299
299
|
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
300
300
|
registration.subscription = registration.trigger$
|
|
301
301
|
.pipe((0, rxjs_1.tap)((ctx) => {
|
|
302
|
-
ctx.log.info('DurableInterpreter.executionStarted', {
|
|
302
|
+
ctx.log.info('DurableInterpreter.executionStarted', {});
|
|
303
303
|
}), (0, rxjs_1.mergeMap)((ctx) => (0, rxjs_1.of)(ctx).pipe(registration.task$, (0, rxjs_1.catchError)((err) => {
|
|
304
304
|
ctx.log.error('DurableInterpreter.executionError', {
|
|
305
305
|
error: err instanceof Error ? err.toString() : err,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAuG9C;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAIhG,CAAC"}
|
|
@@ -27,6 +27,7 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
27
27
|
signal.addEventListener('abort', cleanup, { once: true });
|
|
28
28
|
let consecutiveErrors = 0;
|
|
29
29
|
const maxConsecutiveErrors = 5;
|
|
30
|
+
let currentlyRunningTasks = trigger.options.limit ?? 0;
|
|
30
31
|
(async () => {
|
|
31
32
|
while (true) {
|
|
32
33
|
if (signal.aborted) {
|
|
@@ -41,12 +42,13 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
41
42
|
break;
|
|
42
43
|
}
|
|
43
44
|
try {
|
|
45
|
+
const fetchLimit = (trigger.options.limit ?? 10) - currentlyRunningTasks;
|
|
44
46
|
// Right now the API itself will hang for a period of time if no workflows are available.
|
|
45
47
|
// so we don't need to add a delay here.
|
|
46
48
|
const wfs = await ctx.queueProvider.fetchWorkflows({
|
|
47
49
|
group: trigger.id,
|
|
48
50
|
ttl: trigger.options.ttl,
|
|
49
|
-
limit:
|
|
51
|
+
limit: fetchLimit,
|
|
50
52
|
});
|
|
51
53
|
if (!wfs) {
|
|
52
54
|
continue;
|
|
@@ -72,6 +74,7 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
72
74
|
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata.executionId ?? (0, mod_js_1.ulid)().toString(), {
|
|
73
75
|
workflow: wf,
|
|
74
76
|
onSuccess: (completedContext) => {
|
|
77
|
+
currentlyRunningTasks--;
|
|
75
78
|
// locked status means we own the workflow and it's not completed yet
|
|
76
79
|
if (wf.status !== 'locked') {
|
|
77
80
|
return;
|
|
@@ -82,8 +85,12 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
82
85
|
status: 'completed',
|
|
83
86
|
});
|
|
84
87
|
},
|
|
88
|
+
onError: (_errorContext) => {
|
|
89
|
+
currentlyRunningTasks--;
|
|
90
|
+
},
|
|
85
91
|
});
|
|
86
92
|
consecutiveErrors = 0;
|
|
93
|
+
currentlyRunningTasks++;
|
|
87
94
|
subscriber.next(newContext);
|
|
88
95
|
}
|
|
89
96
|
}
|
|
@@ -279,7 +279,7 @@ class MemoryInterpreter {
|
|
|
279
279
|
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
280
280
|
registration.subscription = registration.trigger$
|
|
281
281
|
.pipe((0, rxjs_1.tap)((ctx) => {
|
|
282
|
-
ctx.log.info('MemoryInterpreter.executionStarted', {
|
|
282
|
+
ctx.log.info('MemoryInterpreter.executionStarted', {});
|
|
283
283
|
}), (0, rxjs_1.mergeMap)((ctx) => (0, rxjs_1.of)(ctx).pipe(registration.task$, (0, rxjs_1.catchError)((err) => {
|
|
284
284
|
ctx.log.error('MemoryInterpreter.executionError', {
|
|
285
285
|
error: err instanceof Error ? err.toString() : err,
|