@dads-framework/job-queue 0.1.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +56 -3
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -4,10 +4,63 @@
4
4
  named work, inspect progress, and close on shutdown. Drivers by env:
5
5
  `in-process` (tests/dev; non-durable) and `bullmq` (Redis; durable retries).
6
6
  A job parses its payload and calls one mutation — business logic never lives
7
- here. Each application owns a stable queue name; worker concurrency and Redis
8
- history are bounded explicitly. See
9
- `docs/reference/job-queue.md`.
7
+ here. Each application owns a stable queue name. Set worker concurrency and
8
+ Redis history bounds explicitly.
10
9
 
11
10
  The package re-exports job definitions and the queue contract from
12
11
  [`@dads-framework/job-queue-core`](../job-queue-core/README.md). The shared
13
12
  provider suite runs against the in-memory fake and the Redis-backed driver.
13
+
14
+ ## Try it
15
+
16
+ In a project using Node.js 22 or later, install the example dependencies.
17
+
18
+ ```sh
19
+ npm install @dads-framework/job-queue zod@4
20
+ npm install -D tsx
21
+ ```
22
+
23
+ Save this as `example.mts` and run `npx tsx example.mts`.
24
+
25
+ <!-- dads:check-example -->
26
+
27
+ ```ts
28
+ import { createJobQueue, defineJob } from "@dads-framework/job-queue";
29
+ import { z } from "zod";
30
+
31
+ const queue = createJobQueue(
32
+ { driver: "in-process", queueName: "reports" },
33
+ {
34
+ info: () => undefined,
35
+ error: console.error,
36
+ },
37
+ );
38
+ queue.register([
39
+ defineJob({
40
+ name: "report-ready",
41
+ payload: z.object({ reportId: z.string() }),
42
+ retry: { attempts: 1, backoffMs: 1 },
43
+ schedules: [],
44
+ run: async ({ reportId }) => {
45
+ console.log(`Report ${reportId} is ready`);
46
+ },
47
+ }),
48
+ ]);
49
+ await queue.start();
50
+ try {
51
+ await queue.enqueue("report-ready", { reportId: "daily" });
52
+ } finally {
53
+ await queue.close();
54
+ }
55
+ console.log((await queue.inspect()).counts.completed);
56
+ ```
57
+
58
+ The script prints `Report daily is ready` and `1` completed job. The in-process driver finishes accepted work on close and runs without Redis.
59
+
60
+ The starter creates the in-process queue and closes it when the service scope is disposed. [`apps/kit-workbench/assembly/local-services.ts`](../../../apps/kit-workbench/assembly/local-services.ts)
61
+
62
+ ## Use it
63
+
64
+ In an application, register its job definitions before `start()`, then
65
+ enqueue work by registered name. Choose `bullmq` and supply `redisUrl` when
66
+ jobs must survive a process restart.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dads-framework/job-queue",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -20,9 +20,9 @@
20
20
  "README.md"
21
21
  ],
22
22
  "dependencies": {
23
- "@dads-framework/audit-actor": "0.1.0",
24
- "@dads-framework/diagnostics": "0.1.0",
25
- "@dads-framework/job-queue-core": "0.1.0",
23
+ "@dads-framework/audit-actor": "0.2.0",
24
+ "@dads-framework/diagnostics": "0.2.0",
25
+ "@dads-framework/job-queue-core": "0.2.0",
26
26
  "bullmq": "^5.79.3"
27
27
  },
28
28
  "devDependencies": {