queue-jobs-worker 1.0.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 (50) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/LICENSE +21 -0
  3. package/README.md +821 -0
  4. package/dist/core/backoff.d.ts +24 -0
  5. package/dist/core/backoff.d.ts.map +1 -0
  6. package/dist/core/client.d.ts +93 -0
  7. package/dist/core/client.d.ts.map +1 -0
  8. package/dist/core/id.d.ts +9 -0
  9. package/dist/core/id.d.ts.map +1 -0
  10. package/dist/core/index.d.ts +7 -0
  11. package/dist/core/index.d.ts.map +1 -0
  12. package/dist/core/job.d.ts +75 -0
  13. package/dist/core/job.d.ts.map +1 -0
  14. package/dist/core/queue.d.ts +70 -0
  15. package/dist/core/queue.d.ts.map +1 -0
  16. package/dist/core/worker.d.ts +65 -0
  17. package/dist/core/worker.d.ts.map +1 -0
  18. package/dist/events/emitter.d.ts +24 -0
  19. package/dist/events/emitter.d.ts.map +1 -0
  20. package/dist/index.cjs +2229 -0
  21. package/dist/index.cjs.map +1 -0
  22. package/dist/index.d.ts +39 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +2219 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/storage/in-memory.adapter.d.ts +32 -0
  27. package/dist/storage/in-memory.adapter.d.ts.map +1 -0
  28. package/dist/storage/index.d.ts +5 -0
  29. package/dist/storage/index.d.ts.map +1 -0
  30. package/dist/storage/mysql.adapter.d.ts +37 -0
  31. package/dist/storage/mysql.adapter.d.ts.map +1 -0
  32. package/dist/storage/postgres.adapter.d.ts +37 -0
  33. package/dist/storage/postgres.adapter.d.ts.map +1 -0
  34. package/dist/storage/redis.adapter.d.ts +44 -0
  35. package/dist/storage/redis.adapter.d.ts.map +1 -0
  36. package/dist/types/client.types.d.ts +41 -0
  37. package/dist/types/client.types.d.ts.map +1 -0
  38. package/dist/types/events.types.d.ts +22 -0
  39. package/dist/types/events.types.d.ts.map +1 -0
  40. package/dist/types/index.d.ts +10 -0
  41. package/dist/types/index.d.ts.map +1 -0
  42. package/dist/types/job.types.d.ts +97 -0
  43. package/dist/types/job.types.d.ts.map +1 -0
  44. package/dist/types/queue.types.d.ts +43 -0
  45. package/dist/types/queue.types.d.ts.map +1 -0
  46. package/dist/types/storage.types.d.ts +120 -0
  47. package/dist/types/storage.types.d.ts.map +1 -0
  48. package/dist/types/worker.types.d.ts +25 -0
  49. package/dist/types/worker.types.d.ts.map +1 -0
  50. package/package.json +97 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,76 @@
1
+ # Changelog
2
+
3
+ All notable changes to **queue-jobs-worker** will be documented in this file.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
+ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [1.0.0] — 2026-08-29
11
+
12
+ ### Added
13
+
14
+ **Core**
15
+
16
+ - `QueueClient` — primary entry point; configures storage, exposes queues, and coordinates lifecycle.
17
+ - `Queue` — independent job stream with per-queue configuration overrides.
18
+ - `Job` — rich wrapper around the raw job data record; passed to user processors.
19
+ - `Worker` — claims and executes jobs with configurable concurrency and graceful shutdown.
20
+ - `QueueEventEmitter` — strongly-typed lifecycle event bus shared across all components.
21
+
22
+ **Job processing**
23
+
24
+ - At-least-once delivery guarantee.
25
+ - Stable job identity preserved across all retries (no duplicate job IDs).
26
+ - Full attempt history stored per job.
27
+ - Per-job processor timeout enforcement.
28
+ - Priority-ordered job claiming (higher priority = claimed first).
29
+ - Delayed and scheduled job support via `schedule.delay` and `schedule.runAt`.
30
+ - Recurring job support via `schedule.cron` field (cron expression stored; recurrence integration point provided).
31
+
32
+ **Reliability**
33
+
34
+ - Configurable retry with `attempts`, `retryDelay`, and `backoff` strategy.
35
+ - Three backoff strategies: `fixed`, `linear`, `exponential` (capped at 10 minutes).
36
+ - Dead Letter Queue (DLQ): jobs moved to `dead` status after exhausting all attempts.
37
+ - Stalled-job recovery: expired locks on `active` jobs are detected and re-queued automatically.
38
+ - Configurable lock duration (`lockDuration`) per queue.
39
+
40
+ **Concurrency**
41
+
42
+ - Per-worker concurrency limit (`concurrency`).
43
+ - Atomic job claiming inside `InMemoryStorageAdapter` (single event-loop tick).
44
+
45
+ **Rate limiting**
46
+
47
+ - Sliding-window rate limiter configurable per queue (`rateLimit.max` / `rateLimit.duration`).
48
+
49
+ **Storage**
50
+
51
+ - `StorageAdapter` interface — clean abstraction; all core logic talks through this interface.
52
+ - `InMemoryStorageAdapter` — full-featured in-process adapter for development and testing.
53
+
54
+ **Configuration**
55
+
56
+ - Layered configuration: Client defaults → Queue options → Worker options → Job options.
57
+ - `QueueClient.withAdapter()` static factory for supplying a custom storage adapter.
58
+
59
+ **TypeScript**
60
+
61
+ - Full strict TypeScript types with `exactOptionalPropertyTypes` and `noUncheckedIndexedAccess`.
62
+ - All public types exported from the top-level `index.ts`.
63
+
64
+ **Build**
65
+
66
+ - Dual ESM + CJS output via `tsup`.
67
+ - Declaration files (`.d.ts` + `.d.ts.map`) generated via `tsc`.
68
+
69
+ **Tests**
70
+
71
+ - 31 tests across backoff strategies, storage adapter, queue client, and worker behaviour.
72
+ - Coverage: job lifecycle, retry, DLQ, concurrency, stalled recovery, rate limiting, graceful shutdown.
73
+
74
+ ---
75
+
76
+ [1.0.0]: https://github.com/rafidahmed870/queue-jobs-worker/releases/tag/v1.0.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rafid Ahmed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.