@monque/core 1.5.2 → 1.7.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/dist/CHANGELOG.md +44 -0
- package/dist/index.cjs +522 -169
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +83 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +83 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +520 -170
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +3 -0
- package/src/scheduler/monque.ts +112 -27
- package/src/scheduler/services/change-stream-handler.ts +183 -31
- package/src/scheduler/services/index.ts +1 -1
- package/src/scheduler/services/job-manager.ts +151 -114
- package/src/scheduler/services/job-processor.ts +109 -54
- package/src/scheduler/services/job-scheduler.ts +42 -9
- package/src/scheduler/services/lifecycle-manager.ts +77 -17
- package/src/scheduler/services/types.ts +7 -0
- package/src/scheduler/types.ts +14 -0
- package/src/shared/errors.ts +29 -0
- package/src/shared/index.ts +3 -0
- package/src/shared/utils/index.ts +1 -0
- package/src/shared/utils/job-identifiers.ts +71 -0
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @monque/core
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#249](https://github.com/ueberBrot/monque/pull/249) [`2c7c079`](https://github.com/ueberBrot/monque/commit/2c7c0790d96b95efef4db2afb96204999d11cded) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Add deprecation console warning for `defaultConcurrency` and `maxConcurrency` options.
|
|
8
|
+
|
|
9
|
+
- [#260](https://github.com/ueberBrot/monque/pull/260) [`c11798b`](https://github.com/ueberBrot/monque/commit/c11798be15ffb9f78abdc4432a954db4a17a05cc) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Parallelized job acquisition in the poll loop using `Promise.allSettled` to lower wall-clock acquisition latency / reduce serialized DB waits (fans out one `findOneAndUpdate` per free slot).
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#269](https://github.com/ueberBrot/monque/pull/269) [`cb707b9`](https://github.com/ueberBrot/monque/commit/cb707b904406ad92a3bbf833c570a92868e7f3d9) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Validate job names and unique keys at the public API boundary so invalid identifiers fail fast before reaching MongoDB operations.
|
|
14
|
+
|
|
15
|
+
- [#266](https://github.com/ueberBrot/monque/pull/266) [`9c75d1c`](https://github.com/ueberBrot/monque/commit/9c75d1cde5330c4495ed930e4fb20fb5ad86a03e) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Fix `.then()` to `.finally()` in `executePollAndScheduleNext` to ensure the next poll is always scheduled, even if `scheduleNextPoll` throws. This prevents silently swallowed rejections when the callback in `.then()` throws.
|
|
16
|
+
|
|
17
|
+
- [#258](https://github.com/ueberBrot/monque/pull/258) [`218d398`](https://github.com/ueberBrot/monque/commit/218d3983bfb8e6b55d1a185378a4489650d7ec32) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Replace `getActiveJobs()` array allocation with `getActiveJobCount()` in shutdown path. The previous implementation created a throw-away `string[]` on every call just to check `.length`. The new method returns a count directly using `Map.size`, avoiding unnecessary array allocations during shutdown polling.
|
|
18
|
+
|
|
19
|
+
- [#259](https://github.com/ueberBrot/monque/pull/259) [`b0babc4`](https://github.com/ueberBrot/monque/commit/b0babc4c7a87020b39d0622ada388a4adf7d815c) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Replace the O(workers) iteration in `getTotalActiveJobs()` with an O(1) counter that updates on job acquisition and completion.
|
|
20
|
+
|
|
21
|
+
- [#263](https://github.com/ueberBrot/monque/pull/263) [`a30186f`](https://github.com/ueberBrot/monque/commit/a30186f24859bcdd9776fede95c848d1bdac3b32) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Add compound index for job retention to avoid collection scan during cleanup
|
|
22
|
+
|
|
23
|
+
- [#264](https://github.com/ueberBrot/monque/pull/264) [`c2b046e`](https://github.com/ueberBrot/monque/commit/c2b046e13ec08814a9a9cd81415b7815499116a1) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Deduplicate `new Date()` calls in update operations. Instead of creating multiple `new Date()` instances milliseconds apart within the same logical operation, methods like `cancelJob`, `retryJob`, and `completeJob` now capture a single `const now = new Date()` and reuse it for all timestamp fields, ensuring consistent timestamps.
|
|
24
|
+
|
|
25
|
+
- [#265](https://github.com/ueberBrot/monque/pull/265) [`79300c0`](https://github.com/ueberBrot/monque/commit/79300c0d725994f7c9b33e3cf6d6b6217dec26d2) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Optimize `cancelJob`, `retryJob`, and `rescheduleJob` by removing redundant `findOne` pre-checks. These operations now use an optimistic `findOneAndUpdate` first, reducing database round-trips for the common happy paths.
|
|
26
|
+
|
|
27
|
+
- [#262](https://github.com/ueberBrot/monque/pull/262) [`1b6e29f`](https://github.com/ueberBrot/monque/commit/1b6e29fdcde765beeacf26785253b5cf8c96a145) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Removed redundant `$unset` operations for `heartbeatInterval` on job completion/failure to improve performance and retain observability metadata.
|
|
28
|
+
|
|
29
|
+
- [#257](https://github.com/ueberBrot/monque/pull/257) [`d71049d`](https://github.com/ueberBrot/monque/commit/d71049da3054de02f3cdd2ad27c021c82f463060) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Replace the `setInterval(100)` busy-loop in `stop()` with a reactive drain promise that resolves instantly when all active jobs finish.
|
|
30
|
+
|
|
31
|
+
- [#267](https://github.com/ueberBrot/monque/pull/267) [`965f8aa`](https://github.com/ueberBrot/monque/commit/965f8aa90742b9ea8e19685898216c6ad3af5011) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Set maxListeners to 20 on Monque EventEmitter to prevent memory leaks in long-running processes.
|
|
32
|
+
|
|
33
|
+
## 1.6.0
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- [#232](https://github.com/ueberBrot/monque/pull/232) [`c3d2c83`](https://github.com/ueberBrot/monque/commit/c3d2c83b89d3fc8e77ec1958695d05b68f357d8d) Thanks [@ueberBrot](https://github.com/ueberBrot)! - Add adaptive poll scheduling and targeted change stream processing
|
|
38
|
+
|
|
39
|
+
- **Adaptive polling**: When change streams are active, safety polling runs at `safetyPollInterval` (default 30s) instead of the fast `pollInterval`. Falls back to `pollInterval` when change streams are unavailable.
|
|
40
|
+
- **Targeted polling**: Change stream events now leverage the full document to poll only the specific worker(s) for the affected job type, skipping unrelated workers.
|
|
41
|
+
- **Wakeup timers**: Future-dated jobs (`nextRunAt > now`) get a precise wakeup timer instead of waiting for the next poll cycle.
|
|
42
|
+
- **Local pending-job notifications**: Jobs created or moved back to `pending` by the local scheduler now trigger the same targeted polling and wakeup-timer path immediately, avoiding startup races before the change stream cursor is fully ready.
|
|
43
|
+
- **Slot-freed re-polling**: When a job completes or permanently fails, a targeted re-poll immediately picks up the next waiting job for that worker.
|
|
44
|
+
- **Re-poll queuing**: Poll requests arriving while a poll is running are queued and executed after, preventing silently dropped change-stream-triggered polls.
|
|
45
|
+
- New configuration option: `safetyPollInterval` (default: 30000ms).
|
|
46
|
+
|
|
3
47
|
## 1.5.2
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|