@aikirun/worker 0.5.3 → 0.6.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 +10 -9
- 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";
|
|
@@ -280,8 +280,6 @@ var WorkerHandleImpl = class {
|
|
|
280
280
|
let heartbeatInterval;
|
|
281
281
|
let shouldAcknowledge = false;
|
|
282
282
|
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
283
|
const heartbeat = this.subscriberStrategy?.heartbeat;
|
|
286
284
|
if (meta && heartbeat) {
|
|
287
285
|
heartbeatInterval = setInterval(() => {
|
|
@@ -294,6 +292,10 @@ var WorkerHandleImpl = class {
|
|
|
294
292
|
}
|
|
295
293
|
}, this.params.opts?.workflowRun?.heartbeatIntervalMs ?? 3e4);
|
|
296
294
|
}
|
|
295
|
+
const eventsDefinition = workflowVersion[INTERNAL].eventsDefinition;
|
|
296
|
+
const handle = await workflowRunHandle(this.client, workflowRun, eventsDefinition, logger);
|
|
297
|
+
const spinThresholdMs = this.params.opts?.workflowRun?.spinThresholdMs ?? 10;
|
|
298
|
+
const appContext = this.client[INTERNAL].contextFactory ? await this.client[INTERNAL].contextFactory(workflowRun) : null;
|
|
297
299
|
await workflowVersion[INTERNAL].handler(
|
|
298
300
|
workflowRun.input,
|
|
299
301
|
{
|
|
@@ -302,16 +304,15 @@ var WorkerHandleImpl = class {
|
|
|
302
304
|
workflowVersionId: workflowRun.workflowVersionId,
|
|
303
305
|
options: workflowRun.options,
|
|
304
306
|
logger,
|
|
305
|
-
sleep:
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
[INTERNAL]: { handle }
|
|
307
|
+
sleep: createSleeper(handle, logger, { spinThresholdMs }),
|
|
308
|
+
events: createEventWaiters(handle, eventsDefinition, logger),
|
|
309
|
+
[INTERNAL]: { handle, options: { spinThresholdMs } }
|
|
309
310
|
},
|
|
310
311
|
appContext
|
|
311
312
|
);
|
|
312
313
|
shouldAcknowledge = true;
|
|
313
314
|
} catch (error) {
|
|
314
|
-
if (error instanceof WorkflowRunNotExecutableError || error instanceof
|
|
315
|
+
if (error instanceof WorkflowRunNotExecutableError || error instanceof WorkflowRunSuspendedError || error instanceof WorkflowRunFailedError || error instanceof TaskFailedError || isServerConflictError(error)) {
|
|
315
316
|
shouldAcknowledge = true;
|
|
316
317
|
} else {
|
|
317
318
|
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.6.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.6.0",
|
|
22
|
+
"@aikirun/client": "0.6.0",
|
|
23
|
+
"@aikirun/workflow": "0.6.0"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|