@brickkit/redis-world 0.11.0 → 0.13.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/NOTICE +4 -3
- package/README.md +1 -1
- package/bin/setup.js +0 -2
- package/dist/cli-BEHfAdNK.js +65 -0
- package/dist/cli-BEHfAdNK.js.map +1 -0
- package/dist/cli.d.ts +10 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -65
- package/dist/index.d.ts +5 -146
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -2581
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +13 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +4 -0
- package/dist/keys-CqKp_Amk.js +104 -0
- package/dist/keys-CqKp_Amk.js.map +1 -0
- package/dist/world-783VJfKL.js +2452 -0
- package/dist/world-783VJfKL.js.map +1 -0
- package/dist/world-BDW_evdb.d.ts +242 -0
- package/dist/world-BDW_evdb.d.ts.map +1 -0
- package/package.json +18 -14
- package/dist/cli.js.map +0 -1
package/NOTICE
CHANGED
|
@@ -8,10 +8,11 @@ Changes: ported the queue to Workflow SDK v5's single-queue contract; added
|
|
|
8
8
|
atomic reservation and persisted attempt/delivery counters, heartbeat lease
|
|
9
9
|
fencing, owner-checked dedup release, capped retries without message loss,
|
|
10
10
|
v5 routing and binary transport, and new recovery and runtime chaos tests.
|
|
11
|
-
Storage, streaming, retention, and utilities
|
|
12
|
-
@brickkit/bullmq-world v5 implementation in this repository
|
|
11
|
+
Storage, streaming, retention, and utilities came from the
|
|
12
|
+
@brickkit/bullmq-world v5 implementation in this repository, which now uses
|
|
13
|
+
them from this package.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
That v5 implementation is derived from @fantasticfour/world-redis-bullmq
|
|
15
16
|
(https://github.com/vinnymac/worlds, packages/world-redis-bullmq), Apache-2.0.
|
|
16
17
|
Its v5 changes include position-based event IDs, atomic writes, restart
|
|
17
18
|
recovery, independent utilities, and concurrency and chaos tests.
|
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ The optional in-band writer fence, `$retention: '0'` purging, hook token retenti
|
|
|
90
90
|
|
|
91
91
|
## Choosing a World
|
|
92
92
|
|
|
93
|
-
Choose `@brickkit/redis-world` when you want fewer dependencies and a hand-built list queue with durable delays, retries, and worker recovery. Choose `@brickkit/bullmq-world` when you want BullMQ's queue tooling and delivery records. Both use
|
|
93
|
+
Choose `@brickkit/redis-world` when you want fewer dependencies and a hand-built list queue with durable delays, retries, and worker recovery. Choose `@brickkit/bullmq-world` when you want BullMQ's queue tooling and delivery records. Both use the same v5 storage, streaming, and run-retention implementation, which lives in this package; `@brickkit/bullmq-world` depends on it. This package has no BullMQ dependency and no Bull Board integration.
|
|
94
94
|
|
|
95
95
|
BullMQ-only options `jobPrefix`, `stalledInterval`, `maxStalledCount`, `lockDuration`, and `jobRetention` are absent. `keyPrefix` isolates the queue; `heartbeatTtlMs` controls crash recovery. Promotion and orphan checks run about every 100 ms while workers are alive.
|
|
96
96
|
|
package/bin/setup.js
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { i as resolveConfig, r as configFromEnv, t as keys } from "./keys-CqKp_Amk.js";
|
|
2
|
+
import { Redis } from "ioredis";
|
|
3
|
+
// src/internal/env.ts
|
|
4
|
+
/**
|
|
5
|
+
* Load an env file when present without making a `.env` file mandatory.
|
|
6
|
+
*
|
|
7
|
+
* Node 24 provides the parser natively, so published worlds do not need a
|
|
8
|
+
* runtime dependency solely to load local development configuration.
|
|
9
|
+
*/
|
|
10
|
+
function loadOptionalEnvFile(path) {
|
|
11
|
+
try {
|
|
12
|
+
if (path === void 0) process.loadEnvFile();
|
|
13
|
+
else process.loadEnvFile(path);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (error.code !== "ENOENT") throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// src/cli.ts
|
|
19
|
+
async function setupRedis(queue = (keyPrefix) => ({
|
|
20
|
+
binName: "brickkit-redis-world-setup",
|
|
21
|
+
description: `Redis queue: ${keys(keyPrefix).queue.ready}, processing lists and delayed set`
|
|
22
|
+
})) {
|
|
23
|
+
loadOptionalEnvFile();
|
|
24
|
+
const { redis: connectionString, keyPrefix } = resolveConfig(configFromEnv());
|
|
25
|
+
const { binName, description, keyPattern } = queue(keyPrefix);
|
|
26
|
+
console.log("Setting up Redis for Workflow...");
|
|
27
|
+
console.log(`Connection: ${connectionString.replace(/^(\w+:\/\/)([^@]+)@/, "$1[redacted]@")}`);
|
|
28
|
+
console.log(`Key Prefix: ${keyPrefix}`);
|
|
29
|
+
let redis;
|
|
30
|
+
let exitCode = 0;
|
|
31
|
+
try {
|
|
32
|
+
redis = new Redis(connectionString);
|
|
33
|
+
await redis.ping();
|
|
34
|
+
console.log("Successfully connected to Redis!");
|
|
35
|
+
const version = (await redis.info("server")).match(/redis_version:([^\r\n]+)/)?.[1];
|
|
36
|
+
if (version) console.log(`Redis version: ${version}`);
|
|
37
|
+
const existingKeys = await redis.keys(`${keyPrefix}*`);
|
|
38
|
+
if (keyPattern) existingKeys.push(...await redis.keys(keyPattern));
|
|
39
|
+
if (existingKeys.length > 0) {
|
|
40
|
+
console.log(`\nWarning: found ${existingKeys.length} existing workflow keys with prefix "${keyPrefix}"`);
|
|
41
|
+
console.log("\nTo flush existing workflow data, run with FLUSH=true environment variable:");
|
|
42
|
+
console.log(` FLUSH=true npx ${binName}`);
|
|
43
|
+
if (process.env.FLUSH === "true") {
|
|
44
|
+
console.log("\nFlushing existing workflow data...");
|
|
45
|
+
const pipeline = redis.pipeline();
|
|
46
|
+
for (const key of existingKeys) pipeline.del(key);
|
|
47
|
+
await pipeline.exec();
|
|
48
|
+
console.log(`Deleted ${existingKeys.length} keys`);
|
|
49
|
+
}
|
|
50
|
+
} else console.log(`\nNo existing workflow data found (clean slate)`);
|
|
51
|
+
console.log("\nRedis is ready for Workflow DevKit!");
|
|
52
|
+
console.log("\nThe following Redis data structures will be used:");
|
|
53
|
+
console.log(` - Runs, event logs, steps, hooks and streams: ${keyPrefix}*`);
|
|
54
|
+
console.log(` - ${description}`);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
exitCode = 1;
|
|
57
|
+
console.error("Failed to setup Redis:", error);
|
|
58
|
+
} finally {
|
|
59
|
+
await redis?.quit().catch(() => {});
|
|
60
|
+
}
|
|
61
|
+
process.exit(exitCode);
|
|
62
|
+
}
|
|
63
|
+
export { setupRedis as t };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=cli-BEHfAdNK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-BEHfAdNK.js","names":[],"sources":["../src/internal/env.ts","../src/cli.ts"],"sourcesContent":["/**\n * Load an env file when present without making a `.env` file mandatory.\n *\n * Node 24 provides the parser natively, so published worlds do not need a\n * runtime dependency solely to load local development configuration.\n */\nexport function loadOptionalEnvFile(path?: string): void {\n try {\n if (path === undefined) {\n process.loadEnvFile();\n } else {\n process.loadEnvFile(path);\n }\n } catch (error: unknown) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n}\n","import { Redis } from \"ioredis\";\nimport { configFromEnv, resolveConfig } from \"./config.js\";\nimport { loadOptionalEnvFile } from \"./internal/env.js\";\nimport { keys } from \"./keys.js\";\n\n/** What the setup CLI says about, and flushes for, a world's queue. */\nexport interface SetupQueue {\n /** The bin users run, for the FLUSH hint. */\n binName: string;\n /** One line describing the queue's keys. */\n description: string;\n /** Queue keys outside `keyPrefix`, flushed with it. */\n keyPattern?: string;\n}\n\nasync function setupRedis(\n queue: (keyPrefix: string) => SetupQueue = (keyPrefix) => ({\n binName: \"brickkit-redis-world-setup\",\n description: `Redis queue: ${keys(keyPrefix).queue.ready}, processing lists and delayed set`,\n }),\n) {\n loadOptionalEnvFile();\n\n const { redis: connectionString, keyPrefix } = resolveConfig(configFromEnv());\n const { binName, description, keyPattern } = queue(keyPrefix);\n\n console.log(\"Setting up Redis for Workflow...\");\n console.log(\n `Connection: ${connectionString.replace(/^(\\w+:\\/\\/)([^@]+)@/, \"$1[redacted]@\")}`,\n );\n console.log(`Key Prefix: ${keyPrefix}`);\n\n let redis: Redis | undefined;\n let exitCode = 0;\n\n try {\n redis = new Redis(connectionString);\n\n await redis.ping();\n console.log(\"Successfully connected to Redis!\");\n\n const info = await redis.info(\"server\");\n const version = info.match(/redis_version:([^\\r\\n]+)/)?.[1];\n if (version) {\n console.log(`Redis version: ${version}`);\n }\n\n const existingKeys = await redis.keys(`${keyPrefix}*`);\n if (keyPattern) existingKeys.push(...(await redis.keys(keyPattern)));\n if (existingKeys.length > 0) {\n console.log(\n `\\nWarning: found ${existingKeys.length} existing workflow keys with prefix \"${keyPrefix}\"`,\n );\n console.log(\n \"\\nTo flush existing workflow data, run with FLUSH=true environment variable:\",\n );\n console.log(` FLUSH=true npx ${binName}`);\n\n if (process.env.FLUSH === \"true\") {\n console.log(\"\\nFlushing existing workflow data...\");\n const pipeline = redis.pipeline();\n for (const key of existingKeys) {\n pipeline.del(key);\n }\n await pipeline.exec();\n console.log(`Deleted ${existingKeys.length} keys`);\n }\n } else {\n console.log(`\\nNo existing workflow data found (clean slate)`);\n }\n\n console.log(\"\\nRedis is ready for Workflow DevKit!\");\n console.log(\"\\nThe following Redis data structures will be used:\");\n console.log(\n ` - Runs, event logs, steps, hooks and streams: ${keyPrefix}*`,\n );\n console.log(` - ${description}`);\n } catch (error) {\n exitCode = 1;\n console.error(\"Failed to setup Redis:\", error);\n } finally {\n await redis?.quit().catch(() => {});\n }\n\n process.exit(exitCode);\n}\n\nexport { setupRedis };\n"],"mappings":";;;;;;;;;AAMA,SAAgB,oBAAoB,MAAqB;CACvD,IAAI;EACF,IAAI,SAAS,KAAA,GACX,QAAQ,YAAY;OAEpB,QAAQ,YAAY,IAAI;CAE5B,SAAS,OAAgB;EACvB,IAAK,MAAgC,SAAS,UAC5C,MAAM;CAEV;AACF;;ACHA,eAAe,WACb,SAA4C,eAAe;CACzD,SAAS;CACT,aAAa,gBAAgB,KAAK,SAAS,CAAC,CAAC,MAAM,MAAM;AAC3D,IACA;CACA,oBAAoB;CAEpB,MAAM,EAAE,OAAO,kBAAkB,cAAc,cAAc,cAAc,CAAC;CAC5E,MAAM,EAAE,SAAS,aAAa,eAAe,MAAM,SAAS;CAE5D,QAAQ,IAAI,kCAAkC;CAC9C,QAAQ,IACN,eAAe,iBAAiB,QAAQ,uBAAuB,eAAe,GAChF;CACA,QAAQ,IAAI,eAAe,WAAW;CAEtC,IAAI;CACJ,IAAI,WAAW;CAEf,IAAI;EACF,QAAQ,IAAI,MAAM,gBAAgB;EAElC,MAAM,MAAM,KAAK;EACjB,QAAQ,IAAI,kCAAkC;EAG9C,MAAM,WAAU,MADG,MAAM,KAAK,QAAQ,EAAA,CACjB,MAAM,0BAA0B,CAAC,GAAG;EACzD,IAAI,SACF,QAAQ,IAAI,kBAAkB,SAAS;EAGzC,MAAM,eAAe,MAAM,MAAM,KAAK,GAAG,UAAU,EAAE;EACrD,IAAI,YAAY,aAAa,KAAK,GAAI,MAAM,MAAM,KAAK,UAAU,CAAE;EACnE,IAAI,aAAa,SAAS,GAAG;GAC3B,QAAQ,IACN,oBAAoB,aAAa,OAAO,uCAAuC,UAAU,EAC3F;GACA,QAAQ,IACN,8EACF;GACA,QAAQ,IAAI,oBAAoB,SAAS;GAEzC,IAAI,QAAQ,IAAI,UAAU,QAAQ;IAChC,QAAQ,IAAI,sCAAsC;IAClD,MAAM,WAAW,MAAM,SAAS;IAChC,KAAK,MAAM,OAAO,cAChB,SAAS,IAAI,GAAG;IAElB,MAAM,SAAS,KAAK;IACpB,QAAQ,IAAI,WAAW,aAAa,OAAO,MAAM;GACnD;EACF,OACE,QAAQ,IAAI,iDAAiD;EAG/D,QAAQ,IAAI,uCAAuC;EACnD,QAAQ,IAAI,qDAAqD;EACjE,QAAQ,IACN,mDAAmD,UAAU,EAC/D;EACA,QAAQ,IAAI,OAAO,aAAa;CAClC,SAAS,OAAO;EACd,WAAW;EACX,QAAQ,MAAM,0BAA0B,KAAK;CAC/C,UAAU;EACR,MAAM,OAAO,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC;CACpC;CAEA,QAAQ,KAAK,QAAQ;AACvB"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/** What the setup CLI says about, and flushes for, a world's queue. */
|
|
2
|
+
export interface SetupQueue {
|
|
3
|
+
/** The bin users run, for the FLUSH hint. */
|
|
4
|
+
binName: string;
|
|
5
|
+
/** One line describing the queue's keys. */
|
|
6
|
+
description: string;
|
|
7
|
+
/** Queue keys outside `keyPrefix`, flushed with it. */
|
|
8
|
+
keyPattern?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function setupRedis(queue?: (keyPrefix: string) => SetupQueue): Promise<void>;
|
|
4
11
|
export { setupRedis };
|
|
5
12
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","names":[],"sources":["../src/cli.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","names":[],"sources":["../src/cli.ts"],"mappings":";iBAMiB;;EAEf;;EAEA;;EAEA;;iBAGa,WACb,SAAQ,sBAAsB,aAG5B"}
|
package/dist/cli.js
CHANGED
|
@@ -1,65 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/internal/env.ts
|
|
3
|
-
/**
|
|
4
|
-
* Load an env file when present without making a `.env` file mandatory.
|
|
5
|
-
*
|
|
6
|
-
* Node 24 provides the parser natively, so published worlds do not need a
|
|
7
|
-
* runtime dependency solely to load local development configuration.
|
|
8
|
-
*/
|
|
9
|
-
function loadOptionalEnvFile(path) {
|
|
10
|
-
try {
|
|
11
|
-
if (path === void 0) process.loadEnvFile();
|
|
12
|
-
else process.loadEnvFile(path);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
if (error.code !== "ENOENT") throw error;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/cli.ts
|
|
19
|
-
async function setupRedis() {
|
|
20
|
-
loadOptionalEnvFile();
|
|
21
|
-
const connectionString = process.env.WORKFLOW_REDIS_URL || process.env.REDIS_URL || "redis://localhost:6379";
|
|
22
|
-
const keyPrefix = process.env.WORKFLOW_REDIS_KEY_PREFIX || "workflow:";
|
|
23
|
-
console.log("Setting up Redis for Workflow...");
|
|
24
|
-
console.log(`Connection: ${connectionString.replace(/^(\w+:\/\/)([^@]+)@/, "$1[redacted]@")}`);
|
|
25
|
-
console.log(`Key Prefix: ${keyPrefix}`);
|
|
26
|
-
let redis;
|
|
27
|
-
let exitCode = 0;
|
|
28
|
-
try {
|
|
29
|
-
redis = new Redis(connectionString);
|
|
30
|
-
await redis.ping();
|
|
31
|
-
console.log("Successfully connected to Redis!");
|
|
32
|
-
const version = (await redis.info("server")).match(/redis_version:([^\r\n]+)/)?.[1];
|
|
33
|
-
if (version) console.log(`Redis version: ${version}`);
|
|
34
|
-
const existingKeys = await redis.keys(`${keyPrefix}*`);
|
|
35
|
-
if (existingKeys.length > 0) {
|
|
36
|
-
console.log(`\nWarning: found ${existingKeys.length} existing workflow keys with prefix "${keyPrefix}"`);
|
|
37
|
-
console.log("\nTo flush existing workflow data, run with FLUSH=true environment variable:");
|
|
38
|
-
console.log(" FLUSH=true npx brickkit-redis-world-setup");
|
|
39
|
-
if (process.env.FLUSH === "true") {
|
|
40
|
-
console.log("\nFlushing existing workflow data...");
|
|
41
|
-
const pipeline = redis.pipeline();
|
|
42
|
-
for (const key of existingKeys) pipeline.del(key);
|
|
43
|
-
await pipeline.exec();
|
|
44
|
-
console.log(`Deleted ${existingKeys.length} keys`);
|
|
45
|
-
}
|
|
46
|
-
} else console.log(`\nNo existing workflow data found (clean slate)`);
|
|
47
|
-
console.log("\nRedis is ready for Workflow DevKit!");
|
|
48
|
-
console.log("\nThe following Redis data structures will be used:");
|
|
49
|
-
console.log(` - Hashes: ${keyPrefix}run:*, ${keyPrefix}step:*, ${keyPrefix}event:*, ${keyPrefix}hook:*`);
|
|
50
|
-
console.log(` - Sorted Sets: ${keyPrefix}runs:*, ${keyPrefix}steps:*, ${keyPrefix}events:*`);
|
|
51
|
-
console.log(` - Streams: ${keyPrefix}stream:*`);
|
|
52
|
-
console.log(` - Redis queue: ${keyPrefix}queue:flows, processing lists and delayed set`);
|
|
53
|
-
} catch (error) {
|
|
54
|
-
exitCode = 1;
|
|
55
|
-
console.error("Failed to setup Redis:", error);
|
|
56
|
-
} finally {
|
|
57
|
-
await redis?.quit().catch(() => {});
|
|
58
|
-
}
|
|
59
|
-
process.exit(exitCode);
|
|
60
|
-
}
|
|
61
|
-
if (import.meta.url === `file://${process.argv[1]}`) setupRedis();
|
|
62
|
-
//#endregion
|
|
63
|
-
export { setupRedis };
|
|
64
|
-
|
|
65
|
-
//# sourceMappingURL=cli.js.map
|
|
1
|
+
export { t as setupRedis } from "./cli-BEHfAdNK.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,148 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Redis
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** Delete runs that finished more than this many seconds ago. */
|
|
7
|
-
age?: number;
|
|
8
|
-
/** Keep at most this many of the newest runs; delete the rest. */
|
|
9
|
-
count?: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Retention for run data (the run, its event log, steps, hooks, and streams),
|
|
13
|
-
* per terminal status. A status without a policy is kept forever.
|
|
14
|
-
*/
|
|
15
|
-
interface RunRetention {
|
|
16
|
-
completed?: KeepRuns;
|
|
17
|
-
failed?: KeepRuns;
|
|
18
|
-
cancelled?: KeepRuns;
|
|
19
|
-
/** How often each worker looks for expired runs (ms). Default: 60000 */
|
|
20
|
-
sweepIntervalMs?: number;
|
|
21
|
-
/** Runs deleted per status per sweep. Default: 200 */
|
|
22
|
-
batchSize?: number;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/config.d.ts
|
|
26
|
-
interface RedisWorldConfig {
|
|
27
|
-
/**
|
|
28
|
-
* Redis connection URL or connection options
|
|
29
|
-
* Examples:
|
|
30
|
-
* - 'redis://localhost:6379'
|
|
31
|
-
* - 'rediss://username:password@host:6380/0'
|
|
32
|
-
* - { host: 'localhost', port: 6379 }
|
|
33
|
-
*/
|
|
34
|
-
redis: string | RedisOptions;
|
|
35
|
-
/**
|
|
36
|
-
* Number of concurrent workers processing jobs
|
|
37
|
-
* Default: 10
|
|
38
|
-
*/
|
|
39
|
-
queueConcurrency?: number;
|
|
40
|
-
/** Worker liveness TTL in milliseconds. Default 90000; minimum 300.
|
|
41
|
-
* Set above the longest event-loop pause. Renewed every TTL / 3. */
|
|
42
|
-
heartbeatTtlMs?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Optional key prefix for all Redis keys
|
|
45
|
-
* Useful for multi-tenancy or namespace isolation
|
|
46
|
-
* Default: 'workflow:'
|
|
47
|
-
*/
|
|
48
|
-
keyPrefix?: string;
|
|
49
|
-
/**
|
|
50
|
-
* Delivery budget before retries continue at maxBackoffMs. Messages are never silently retired.
|
|
51
|
-
*
|
|
52
|
-
* Keep it above the runtime's own delivery ceiling (48). The runtime records a
|
|
53
|
-
* run as failed (`MAX_DELIVERIES_EXCEEDED`) on delivery 49; a job retired
|
|
54
|
-
* earlier strands its run in `running`, with nothing to redeliver it until a
|
|
55
|
-
* process calls `start()` again.
|
|
56
|
-
* Default: 73
|
|
57
|
-
*/
|
|
58
|
-
maxAttempts?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Backoff strategy for retries: 'fixed' replays at the same interval,
|
|
61
|
-
* 'exponential' doubles the delay on each attempt.
|
|
62
|
-
* Default: 'exponential'
|
|
63
|
-
*/
|
|
64
|
-
backoffType?: "fixed" | "exponential";
|
|
65
|
-
/**
|
|
66
|
-
* Base delay for backoff (ms). For exponential backoff this is multiplied
|
|
67
|
-
* by 2^(attempt - 1), up to `maxBackoffMs`.
|
|
68
|
-
* Default: 1000
|
|
69
|
-
*/
|
|
70
|
-
backoffDelayMs?: number;
|
|
71
|
-
/**
|
|
72
|
-
* The longest a retry is delayed (ms). With the default number of attempts an
|
|
73
|
-
* uncapped exponential backoff would wait hours between late attempts.
|
|
74
|
-
* Default: 30000 (30s)
|
|
75
|
-
*/
|
|
76
|
-
maxBackoffMs?: number;
|
|
77
|
-
/**
|
|
78
|
-
* Base URL the worker uses to dispatch jobs back to the user's HTTP
|
|
79
|
-
* server, which must serve `world.createQueueHandler(...)` at
|
|
80
|
-
* `/.well-known/workflow/v1/flow` (steps travel on the same route). A route
|
|
81
|
-
* registered with `world.registerRoute`, or an in-process handler registered
|
|
82
|
-
* with `world.registerHandler`, takes precedence.
|
|
83
|
-
* Default: process.env.WORKFLOW_BASE_URL || `http://localhost:${process.env.PORT ?? 3000}`
|
|
84
|
-
*/
|
|
85
|
-
baseUrl?: string;
|
|
86
|
-
/**
|
|
87
|
-
* Per-job HTTP request timeout (ms). Long-running workflow steps may need a
|
|
88
|
-
* higher value.
|
|
89
|
-
* Default: 300_000 (5 minutes)
|
|
90
|
-
*/
|
|
91
|
-
httpTimeoutMs?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Optional TTL (ms) for queue deduplication when `idempotencyKey`
|
|
94
|
-
* is supplied to `queue()`. By default no TTL is applied: the dedup key
|
|
95
|
-
* lives until the job is acknowledged, so duplicate enqueues are dropped
|
|
96
|
-
* for the entire lifetime of the pending/delayed job (the semantics the
|
|
97
|
-
* workflow runtime relies on when re-enqueuing pending steps on replay).
|
|
98
|
-
* Only set this if you need the dedup guard to expire on wall-clock time;
|
|
99
|
-
* it must be much larger than the longest expected queue delay/backlog,
|
|
100
|
-
* otherwise duplicate step executions become possible.
|
|
101
|
-
* Default: undefined (dedup key released on job completion)
|
|
102
|
-
*/
|
|
103
|
-
idempotencyTtlMs?: number;
|
|
104
|
-
/** Maximum events a run may accumulate, reported as `EventResult.maxEvents`.
|
|
105
|
-
* Default: `WORKFLOW_MAX_EVENTS` || 25_000 */
|
|
106
|
-
maxEventsPerRun?: number;
|
|
107
|
-
/**
|
|
108
|
-
* Batch commands issued in the same event-loop tick into one write. A win
|
|
109
|
-
* once several runs are in flight (~1.75x at 256 concurrent) and a marginal
|
|
110
|
-
* loss for a single serial caller.
|
|
111
|
-
* Default: true
|
|
112
|
-
*/
|
|
113
|
-
enableAutoPipelining?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* How long finished runs are kept, per terminal status: `age` in seconds,
|
|
116
|
-
* `count` of newest runs to keep. A reaper on each worker deletes the run, its event log, steps, hooks
|
|
117
|
-
* and streams once it passes. A status without a policy is kept forever.
|
|
118
|
-
* Default: undefined (nothing expires)
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* retention: {
|
|
122
|
-
* completed: { age: 24 * 60 * 60, count: 1000 },
|
|
123
|
-
* failed: { age: 7 * 24 * 60 * 60 },
|
|
124
|
-
* }
|
|
125
|
-
*/
|
|
126
|
-
retention?: RunRetention;
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/queue.d.ts
|
|
130
|
-
interface QueueStats {
|
|
131
|
-
waiting: number;
|
|
132
|
-
active: number;
|
|
133
|
-
delayed: number;
|
|
134
|
-
/** Completed and failed delivery records are not retained. */
|
|
135
|
-
completed: number;
|
|
136
|
-
failed: number;
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region src/index.d.ts
|
|
140
|
-
export declare function createWorld(config?: RedisWorldConfig): World & {
|
|
141
|
-
start(): Promise<void>;
|
|
142
|
-
getQueueStats(): Promise<QueueStats>;
|
|
143
|
-
/** Run one retention sweep now; returns the runs deleted. 0 without `retention`. */
|
|
144
|
-
sweepRetention(): Promise<number>;
|
|
145
|
-
};
|
|
146
|
-
//#endregion
|
|
1
|
+
import { _ as RunRetention, a as QueueStats, f as RedisWorldConfig, g as KeepRuns, t as RedisBackedWorld } from "./world-BDW_evdb.js";
|
|
2
|
+
import { Redis } from "ioredis";
|
|
3
|
+
/** `config` is laid over `configFromEnv()`: an option left out comes from the
|
|
4
|
+
* `WORKFLOW_REDIS_*` variables, then the defaults. */
|
|
5
|
+
export declare function createWorld(config?: Partial<RedisWorldConfig>): RedisBackedWorld;
|
|
147
6
|
export type { KeepRuns, QueueStats, RedisWorldConfig, RunRetention };
|
|
148
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;wBAOgB,YACd,SAAQ,QAAQ,oBACf"}
|