@versori/run 0.4.0-alpha.11 → 0.4.0-alpha.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/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +12 -1
- package/package.json +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.js +12 -1
|
@@ -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,CA4G9C;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,17 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
37
38
|
break;
|
|
38
39
|
}
|
|
39
40
|
try {
|
|
41
|
+
const fetchLimit = (trigger.options.limit ?? 10) - currentlyRunningTasks;
|
|
42
|
+
if (fetchLimit <= 0) {
|
|
43
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
40
46
|
// Right now the API itself will hang for a period of time if no workflows are available.
|
|
41
47
|
// so we don't need to add a delay here.
|
|
42
48
|
const wfs = await ctx.queueProvider.fetchWorkflows({
|
|
43
49
|
group: trigger.id,
|
|
44
50
|
ttl: trigger.options.ttl,
|
|
45
|
-
limit:
|
|
51
|
+
limit: fetchLimit,
|
|
46
52
|
});
|
|
47
53
|
if (!wfs) {
|
|
48
54
|
continue;
|
|
@@ -68,6 +74,7 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
68
74
|
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata.executionId ?? ulid().toString(), {
|
|
69
75
|
workflow: wf,
|
|
70
76
|
onSuccess: (completedContext) => {
|
|
77
|
+
currentlyRunningTasks--;
|
|
71
78
|
// locked status means we own the workflow and it's not completed yet
|
|
72
79
|
if (wf.status !== 'locked') {
|
|
73
80
|
return;
|
|
@@ -78,8 +85,12 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
78
85
|
status: 'completed',
|
|
79
86
|
});
|
|
80
87
|
},
|
|
88
|
+
onError: (_errorContext) => {
|
|
89
|
+
currentlyRunningTasks--;
|
|
90
|
+
},
|
|
81
91
|
});
|
|
82
92
|
consecutiveErrors = 0;
|
|
93
|
+
currentlyRunningTasks++;
|
|
83
94
|
subscriber.next(newContext);
|
|
84
95
|
}
|
|
85
96
|
}
|
package/package.json
CHANGED
|
@@ -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,CA4G9C;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,17 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
41
42
|
break;
|
|
42
43
|
}
|
|
43
44
|
try {
|
|
45
|
+
const fetchLimit = (trigger.options.limit ?? 10) - currentlyRunningTasks;
|
|
46
|
+
if (fetchLimit <= 0) {
|
|
47
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
44
50
|
// Right now the API itself will hang for a period of time if no workflows are available.
|
|
45
51
|
// so we don't need to add a delay here.
|
|
46
52
|
const wfs = await ctx.queueProvider.fetchWorkflows({
|
|
47
53
|
group: trigger.id,
|
|
48
54
|
ttl: trigger.options.ttl,
|
|
49
|
-
limit:
|
|
55
|
+
limit: fetchLimit,
|
|
50
56
|
});
|
|
51
57
|
if (!wfs) {
|
|
52
58
|
continue;
|
|
@@ -72,6 +78,7 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
72
78
|
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata.executionId ?? (0, mod_js_1.ulid)().toString(), {
|
|
73
79
|
workflow: wf,
|
|
74
80
|
onSuccess: (completedContext) => {
|
|
81
|
+
currentlyRunningTasks--;
|
|
75
82
|
// locked status means we own the workflow and it's not completed yet
|
|
76
83
|
if (wf.status !== 'locked') {
|
|
77
84
|
return;
|
|
@@ -82,8 +89,12 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
82
89
|
status: 'completed',
|
|
83
90
|
});
|
|
84
91
|
},
|
|
92
|
+
onError: (_errorContext) => {
|
|
93
|
+
currentlyRunningTasks--;
|
|
94
|
+
},
|
|
85
95
|
});
|
|
86
96
|
consecutiveErrors = 0;
|
|
97
|
+
currentlyRunningTasks++;
|
|
87
98
|
subscriber.next(newContext);
|
|
88
99
|
}
|
|
89
100
|
}
|