@aikirun/worker 0.5.3 → 0.7.0
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/dist/index.d.ts +1 -1
- package/dist/index.js +11 -13
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ type TypeOfValueAtPath<T extends object, Path extends PathFromObject<T>> = Path
|
|
|
53
53
|
declare function worker(params: WorkerParams): Worker;
|
|
54
54
|
interface WorkerParams {
|
|
55
55
|
id: string;
|
|
56
|
-
workflows: WorkflowVersion<any, any, any>[];
|
|
56
|
+
workflows: WorkflowVersion<any, any, any, any>[];
|
|
57
57
|
subscriber?: SubscriberStrategy;
|
|
58
58
|
opts?: WorkerOptions;
|
|
59
59
|
}
|
package/dist/index.js
CHANGED
|
@@ -82,13 +82,13 @@ var objectOverrider = (defaultObj) => (obj) => {
|
|
|
82
82
|
import { INTERNAL } from "@aikirun/types/symbols";
|
|
83
83
|
import { TaskFailedError } from "@aikirun/types/task";
|
|
84
84
|
import {
|
|
85
|
-
WorkflowRunCancelledError,
|
|
86
85
|
WorkflowRunFailedError,
|
|
87
86
|
WorkflowRunNotExecutableError,
|
|
88
87
|
WorkflowRunSuspendedError
|
|
89
88
|
} from "@aikirun/types/workflow-run";
|
|
90
89
|
import {
|
|
91
|
-
|
|
90
|
+
createEventWaiters,
|
|
91
|
+
createSleeper,
|
|
92
92
|
workflowRegistry,
|
|
93
93
|
workflowRunHandle
|
|
94
94
|
} from "@aikirun/workflow";
|
|
@@ -272,16 +272,11 @@ var WorkerHandleImpl = class {
|
|
|
272
272
|
"aiki.component": "workflow-execution",
|
|
273
273
|
"aiki.workflowId": workflowRun.workflowId,
|
|
274
274
|
"aiki.workflowVersionId": workflowRun.workflowVersionId,
|
|
275
|
-
"aiki.workflowRunId": workflowRun.id
|
|
276
|
-
...meta && {
|
|
277
|
-
"aiki.messageId": meta.messageId
|
|
278
|
-
}
|
|
275
|
+
"aiki.workflowRunId": workflowRun.id
|
|
279
276
|
});
|
|
280
277
|
let heartbeatInterval;
|
|
281
278
|
let shouldAcknowledge = false;
|
|
282
279
|
try {
|
|
283
|
-
const handle = await workflowRunHandle(this.client, workflowRun, logger);
|
|
284
|
-
const appContext = this.client[INTERNAL].contextFactory ? await this.client[INTERNAL].contextFactory(workflowRun) : null;
|
|
285
280
|
const heartbeat = this.subscriberStrategy?.heartbeat;
|
|
286
281
|
if (meta && heartbeat) {
|
|
287
282
|
heartbeatInterval = setInterval(() => {
|
|
@@ -294,6 +289,10 @@ var WorkerHandleImpl = class {
|
|
|
294
289
|
}
|
|
295
290
|
}, this.params.opts?.workflowRun?.heartbeatIntervalMs ?? 3e4);
|
|
296
291
|
}
|
|
292
|
+
const eventsDefinition = workflowVersion[INTERNAL].eventsDefinition;
|
|
293
|
+
const handle = await workflowRunHandle(this.client, workflowRun, eventsDefinition, logger);
|
|
294
|
+
const spinThresholdMs = this.params.opts?.workflowRun?.spinThresholdMs ?? 10;
|
|
295
|
+
const appContext = this.client[INTERNAL].contextFactory ? await this.client[INTERNAL].contextFactory(workflowRun) : null;
|
|
297
296
|
await workflowVersion[INTERNAL].handler(
|
|
298
297
|
workflowRun.input,
|
|
299
298
|
{
|
|
@@ -302,16 +301,15 @@ var WorkerHandleImpl = class {
|
|
|
302
301
|
workflowVersionId: workflowRun.workflowVersionId,
|
|
303
302
|
options: workflowRun.options,
|
|
304
303
|
logger,
|
|
305
|
-
sleep:
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
[INTERNAL]: { handle }
|
|
304
|
+
sleep: createSleeper(handle, logger, { spinThresholdMs }),
|
|
305
|
+
events: createEventWaiters(handle, eventsDefinition, logger),
|
|
306
|
+
[INTERNAL]: { handle, options: { spinThresholdMs } }
|
|
309
307
|
},
|
|
310
308
|
appContext
|
|
311
309
|
);
|
|
312
310
|
shouldAcknowledge = true;
|
|
313
311
|
} catch (error) {
|
|
314
|
-
if (error instanceof WorkflowRunNotExecutableError || error instanceof
|
|
312
|
+
if (error instanceof WorkflowRunNotExecutableError || error instanceof WorkflowRunSuspendedError || error instanceof WorkflowRunFailedError || error instanceof TaskFailedError || isServerConflictError(error)) {
|
|
315
313
|
shouldAcknowledge = true;
|
|
316
314
|
} else {
|
|
317
315
|
logger.error("Unexpected error during workflow execution", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikirun/worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Worker SDK for Aiki - execute workflows and tasks with durable state management and automatic recovery",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"build": "tsup"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@aikirun/types": "0.
|
|
22
|
-
"@aikirun/client": "0.
|
|
23
|
-
"@aikirun/workflow": "0.
|
|
21
|
+
"@aikirun/types": "0.7.0",
|
|
22
|
+
"@aikirun/client": "0.7.0",
|
|
23
|
+
"@aikirun/workflow": "0.7.0"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|