@aikirun/client 0.7.0 → 0.8.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 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ npm install @aikirun/client
|
|
|
16
16
|
import { client } from "@aikirun/client";
|
|
17
17
|
|
|
18
18
|
const aikiClient = await client({
|
|
19
|
-
url: "http://localhost:
|
|
19
|
+
url: "http://localhost:9876",
|
|
20
20
|
redis: {
|
|
21
21
|
host: "localhost",
|
|
22
22
|
port: 6379,
|
|
@@ -90,7 +90,7 @@ interface ClientParams<AppContext> {
|
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
92
|
const aikiClient = await client({
|
|
93
|
-
url: "http://localhost:
|
|
93
|
+
url: "http://localhost:9876",
|
|
94
94
|
redis: { host: "localhost", port: 6379 },
|
|
95
95
|
contextFactory: (run) => ({
|
|
96
96
|
traceId: generateTraceId(),
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { AdaptivePollingSubscriberStrategy, ApiClient, Client, ClientParams, Log
|
|
|
9
9
|
*
|
|
10
10
|
* @template AppContext - Type of application context passed to workflows (default: null)
|
|
11
11
|
* @param params - Client configuration parameters
|
|
12
|
-
* @param params.url - HTTP URL of the Aiki server (e.g., "http://localhost:
|
|
12
|
+
* @param params.url - HTTP URL of the Aiki server (e.g., "http://localhost:9876")
|
|
13
13
|
* @param params.redis - Redis connection configuration
|
|
14
14
|
* @param params.redis.host - Redis server hostname
|
|
15
15
|
* @param params.redis.port - Redis server port
|
|
@@ -21,7 +21,7 @@ export { AdaptivePollingSubscriberStrategy, ApiClient, Client, ClientParams, Log
|
|
|
21
21
|
* @example
|
|
22
22
|
* ```typescript
|
|
23
23
|
* const aikiClient = await client({
|
|
24
|
-
* url: "http://localhost:
|
|
24
|
+
* url: "http://localhost:9876",
|
|
25
25
|
* redis: { host: "localhost", port: 6379 },
|
|
26
26
|
* contextFactory: (run) => ({
|
|
27
27
|
* traceId: generateTraceId(),
|
package/dist/index.js
CHANGED
|
@@ -69,6 +69,14 @@ function distributeRoundRobin(totalSize, itemCount) {
|
|
|
69
69
|
return distribution;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
// ../../lib/path/index.ts
|
|
73
|
+
function getWorkflowStreamName(name, versionId, shard) {
|
|
74
|
+
return shard ? `workflow/${name}/${versionId}/${shard}` : `workflow/${name}/${versionId}`;
|
|
75
|
+
}
|
|
76
|
+
function getWorkerConsumerGroupName(workflowName, workflowVersionId, shard) {
|
|
77
|
+
return shard ? `worker/${workflowName}/${workflowVersionId}/${shard}` : `worker/${workflowName}/${workflowVersionId}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
72
80
|
// ../../lib/retry/strategy.ts
|
|
73
81
|
function getRetryParams(attempts, strategy) {
|
|
74
82
|
const strategyType = strategy.type;
|
|
@@ -208,10 +216,6 @@ function createRedisStreamsStrategy(client2, strategy, workflows, workerShards)
|
|
|
208
216
|
"aiki.messageId": meta.messageId
|
|
209
217
|
});
|
|
210
218
|
} else {
|
|
211
|
-
logger.debug("Message acknowledged", {
|
|
212
|
-
"aiki.workflowRunId": workflowRunId,
|
|
213
|
-
"aiki.messageId": meta.messageId
|
|
214
|
-
});
|
|
215
219
|
}
|
|
216
220
|
} catch (error) {
|
|
217
221
|
logger.error("Failed to acknowledge message", {
|
|
@@ -252,20 +256,20 @@ function createRedisStreamsStrategy(client2, strategy, workflows, workerShards)
|
|
|
252
256
|
}
|
|
253
257
|
};
|
|
254
258
|
}
|
|
255
|
-
function getRedisStreamConsumerGroupMap(workflows,
|
|
256
|
-
if (!
|
|
259
|
+
function getRedisStreamConsumerGroupMap(workflows, shards) {
|
|
260
|
+
if (!shards || !isNonEmptyArray(shards)) {
|
|
257
261
|
return new Map(
|
|
258
262
|
workflows.map((workflow) => [
|
|
259
|
-
|
|
260
|
-
|
|
263
|
+
getWorkflowStreamName(workflow.name, workflow.versionId),
|
|
264
|
+
getWorkerConsumerGroupName(workflow.name, workflow.versionId)
|
|
261
265
|
])
|
|
262
266
|
);
|
|
263
267
|
}
|
|
264
268
|
return new Map(
|
|
265
269
|
workflows.flatMap(
|
|
266
|
-
(workflow) =>
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
(workflow) => shards.map((shard) => [
|
|
271
|
+
getWorkflowStreamName(workflow.name, workflow.versionId, shard),
|
|
272
|
+
getWorkerConsumerGroupName(workflow.name, workflow.versionId, shard)
|
|
269
273
|
])
|
|
270
274
|
)
|
|
271
275
|
);
|
|
@@ -332,7 +336,6 @@ async function fetchRedisStreamMessages(redis, logger, streams, streamConsumerGr
|
|
|
332
336
|
async function processRedisStreamMessages(redis, logger, streamConsumerGroupMap, streamsEntries) {
|
|
333
337
|
const workflowRuns = [];
|
|
334
338
|
for (const streamEntriesRaw of streamsEntries) {
|
|
335
|
-
logger.debug("Raw stream entries", { entries: streamEntriesRaw });
|
|
336
339
|
const streamEntriesResult = RedisStreamEntriesSchema.safeParse(streamEntriesRaw);
|
|
337
340
|
if (!streamEntriesResult.success) {
|
|
338
341
|
logger.error("Invalid stream entries format", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikirun/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Client SDK for Aiki - connect to the server, start workflows, and manage execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build": "tsup"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@aikirun/types": "0.
|
|
21
|
+
"@aikirun/types": "0.8.0",
|
|
22
22
|
"@orpc/client": "^1.9.3",
|
|
23
23
|
"ioredis": "^5.4.1",
|
|
24
24
|
"zod": "^4.1.12"
|