You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+3-21Lines changed: 3 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,9 @@ This is `adapter-queue`, a TypeScript queue system inspired by Yii2-Queue archit
12
12
- Define job types as TypeScript interfaces (not classes) for type safety
13
13
- Register job handlers using type-safe `setHandlers()` method
14
14
- Add jobs to queues with compile-time validation of payloads and options
15
-
- Process jobs asynchronously with configurable workers
15
+
- Process jobs asynchronously
16
16
- Switch between storage backends (File, Database, SQS) without changing job code
17
17
- Monitor job lifecycle through built-in events
18
-
- Run jobs in isolated processes for improved stability
19
18
20
19
Key differentiator: Unlike traditional job queue systems that require job classes, this uses an event-based approach where you define job types as interfaces and register handlers as functions, making it simpler and more TypeScript-friendly.
21
20
@@ -27,18 +26,6 @@ Key differentiator: Unlike traditional job queue systems that require job classe
27
26
-`pnpm run lint` - Type checking with TypeScript compiler
28
27
-`pnpm test` - Run all tests with Vitest
29
28
30
-
### Worker Commands
31
-
-`pnpm run queue:worker` - Start a queue worker
32
-
-`pnpm run queue:worker:isolate` - Start worker with job isolation
33
-
34
-
### CLI Worker Options
35
-
The CLI worker supports these arguments:
36
-
-`--driver <type>` - Queue driver: 'db' or 'sqs' (default: db)
37
-
-`--isolate` - Run jobs in isolated child processes
38
-
-`--no-repeat` - Run once and exit (default: run continuously)
39
-
-`--timeout <sec>` - Polling timeout in seconds (default: 3)
40
-
-`--queue-url <url>` - SQS queue URL (required for SQS driver)
41
-
42
29
## Architecture Overview
43
30
44
31
### Core Components
@@ -49,8 +36,7 @@ The CLI worker supports these arguments:
-**FileQueue** (`src/drivers/file.ts`): File-based queue storing jobs as individual files with JSON index
51
38
3.**Jobs**: Defined as TypeScript interfaces in a JobMap, with handlers registered via `setHandlers()` method
52
-
4.**Workers**: Long-running processes that consume and execute jobs
53
-
5.**Serialization**: Pluggable serialization system for job payloads
39
+
4.**Serialization**: Pluggable serialization system for job payloads
54
40
55
41
### Key Interfaces
56
42
@@ -89,17 +75,13 @@ When implementing DatabaseAdapter, you must provide:
89
75
- Uses Vitest for testing
90
76
- Test setup file: `tests/setup.ts`
91
77
- Mock implementations available in `tests/mocks/`
92
-
- Tests organized by component: `core/`, `drivers/`, `worker/`
93
-
94
-
### Worker Isolation
95
-
Workers can run jobs in isolated child processes using the `--isolate` flag or `isolate: true` option. This improves stability by preventing job failures from crashing the worker process.
78
+
- Tests organized by component: `core/`, `drivers/`
96
79
97
80
## Example Project
98
81
The `example-queue-project/` directory contains a working example with SQLite database adapter implementation.
99
82
100
83
## Important Notes
101
84
102
-
- The CLI worker is a template - it requires user-provided database adapters or SQS clients
103
85
- Jobs are serialized as JSON strings (job name + payload) and stored as Buffers in database adapters
104
86
- TTR (Time To Run) defaults to 300 seconds but can be configured per job
105
87
- SQS driver uses message attributes for metadata and base64 encoding for payloads
0 commit comments