@aikirun/worker 0.24.3 → 0.26.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/README.md +2 -3
- package/dist/index.js +34 -34
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ process.on("SIGTERM", async () => {
|
|
|
40
40
|
- **Heartbeat Monitoring** - Detect and recover stuck workflows
|
|
41
41
|
- **Graceful Shutdown** - Complete active work before stopping
|
|
42
42
|
- **Sharding** - Route workflows to specific workers
|
|
43
|
-
- **Pluggable Subscribers** - Swap work discovery transport (DB polling default, Redis Streams via `@aikirun/
|
|
43
|
+
- **Pluggable Subscribers** - Swap work discovery transport (DB polling default, Redis Streams via `@aikirun/redis`, or bring your own)
|
|
44
44
|
|
|
45
45
|
## Documentation
|
|
46
46
|
|
|
@@ -49,8 +49,7 @@ For comprehensive documentation including scaling strategies, configuration opti
|
|
|
49
49
|
## Related Packages
|
|
50
50
|
|
|
51
51
|
- [@aikirun/client](https://www.npmjs.com/package/@aikirun/client) - Connect to Aiki server
|
|
52
|
-
- [@aikirun/workflow](https://www.npmjs.com/package/@aikirun/workflow) - Define workflows
|
|
53
|
-
- [@aikirun/task](https://www.npmjs.com/package/@aikirun/task) - Define tasks
|
|
52
|
+
- [@aikirun/workflow](https://www.npmjs.com/package/@aikirun/workflow) - Define workflows and tasks
|
|
54
53
|
|
|
55
54
|
## License
|
|
56
55
|
|
package/dist/index.js
CHANGED
|
@@ -22,36 +22,6 @@ function delay(ms, options) {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// ../../lib/object/overrider.ts
|
|
26
|
-
function set(obj, path, value) {
|
|
27
|
-
const keys = path.split(".");
|
|
28
|
-
let currentValue = obj;
|
|
29
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
30
|
-
const key = keys[i];
|
|
31
|
-
let nextValue = currentValue[key];
|
|
32
|
-
if (nextValue === void 0 || nextValue === null) {
|
|
33
|
-
nextValue = {};
|
|
34
|
-
currentValue[key] = nextValue;
|
|
35
|
-
}
|
|
36
|
-
currentValue = nextValue;
|
|
37
|
-
}
|
|
38
|
-
const lastKey = keys[keys.length - 1];
|
|
39
|
-
currentValue[lastKey] = value;
|
|
40
|
-
}
|
|
41
|
-
var objectOverrider = (defaultObj) => (obj) => {
|
|
42
|
-
const createBuilder = (overrides) => ({
|
|
43
|
-
with: (path, value) => createBuilder([...overrides, { path: `${path}`, value }]),
|
|
44
|
-
build: () => {
|
|
45
|
-
const clonedObject = structuredClone(obj ?? defaultObj);
|
|
46
|
-
for (const { path, value } of overrides) {
|
|
47
|
-
set(clonedObject, path, value);
|
|
48
|
-
}
|
|
49
|
-
return clonedObject;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return createBuilder([]);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
25
|
// ../../lib/retry/strategy.ts
|
|
56
26
|
function getRetryParams(attempts, strategy) {
|
|
57
27
|
const strategyType = strategy.type;
|
|
@@ -100,8 +70,8 @@ function getRetryParams(attempts, strategy) {
|
|
|
100
70
|
}
|
|
101
71
|
}
|
|
102
72
|
|
|
103
|
-
// ../
|
|
104
|
-
function
|
|
73
|
+
// ../transport/http/subscriber.ts
|
|
74
|
+
function httpSubscriber(params) {
|
|
105
75
|
const { api, options } = params;
|
|
106
76
|
const intervalMs = options?.intervalMs ?? 1e3;
|
|
107
77
|
const maxRetryIntervalMs = options?.maxRetryIntervalMs ?? 3e4;
|
|
@@ -153,6 +123,36 @@ function dbSubscriber(params) {
|
|
|
153
123
|
};
|
|
154
124
|
}
|
|
155
125
|
|
|
126
|
+
// ../../lib/object/overrider.ts
|
|
127
|
+
function set(obj, path, value) {
|
|
128
|
+
const keys = path.split(".");
|
|
129
|
+
let currentValue = obj;
|
|
130
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
131
|
+
const key = keys[i];
|
|
132
|
+
let nextValue = currentValue[key];
|
|
133
|
+
if (nextValue === void 0 || nextValue === null) {
|
|
134
|
+
nextValue = {};
|
|
135
|
+
currentValue[key] = nextValue;
|
|
136
|
+
}
|
|
137
|
+
currentValue = nextValue;
|
|
138
|
+
}
|
|
139
|
+
const lastKey = keys[keys.length - 1];
|
|
140
|
+
currentValue[lastKey] = value;
|
|
141
|
+
}
|
|
142
|
+
var objectOverrider = (defaultObj) => (obj) => {
|
|
143
|
+
const createBuilder = (overrides) => ({
|
|
144
|
+
with: (path, value) => createBuilder([...overrides, { path: `${path}`, value }]),
|
|
145
|
+
build: () => {
|
|
146
|
+
const clonedObject = structuredClone(obj ?? defaultObj);
|
|
147
|
+
for (const { path, value } of overrides) {
|
|
148
|
+
set(clonedObject, path, value);
|
|
149
|
+
}
|
|
150
|
+
return clonedObject;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return createBuilder([]);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
156
|
// worker.ts
|
|
157
157
|
import {
|
|
158
158
|
executeWorkflowRun,
|
|
@@ -215,10 +215,10 @@ var WorkerHandleImpl = class {
|
|
|
215
215
|
shards: this.spawnOptions.shards,
|
|
216
216
|
logger: this.logger
|
|
217
217
|
};
|
|
218
|
-
const createSubscriber = this.params.subscriber ??
|
|
218
|
+
const createSubscriber = this.params.subscriber ?? httpSubscriber({ api: this.client.api });
|
|
219
219
|
const subscriber = createSubscriber(subscriberContext);
|
|
220
220
|
this.subscriber = subscriber instanceof Promise ? await subscriber : subscriber;
|
|
221
|
-
const createFallbackSubscriber =
|
|
221
|
+
const createFallbackSubscriber = httpSubscriber({ api: this.client.api });
|
|
222
222
|
const fallbackSubscriber = createFallbackSubscriber(subscriberContext);
|
|
223
223
|
this.fallbackSubscriber = fallbackSubscriber instanceof Promise ? await fallbackSubscriber : fallbackSubscriber;
|
|
224
224
|
this.abortController = new AbortController();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikirun/worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.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,8 @@
|
|
|
18
18
|
"build": "tsup"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@aikirun/types": "0.
|
|
22
|
-
"@aikirun/
|
|
23
|
-
"@aikirun/workflow": "0.24.3",
|
|
21
|
+
"@aikirun/types": "0.26.0",
|
|
22
|
+
"@aikirun/workflow": "0.26.0",
|
|
24
23
|
"ulidx": "^2.4.1"
|
|
25
24
|
},
|
|
26
25
|
"publishConfig": {
|