glide-mq 0.7.0 → 0.8.1
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/CHANGELOG.md +108 -0
- package/LICENSE +191 -0
- package/README.md +79 -47
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +5 -3
- package/dist/connection.js.map +1 -1
- package/dist/errors.d.ts +3 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +8 -1
- package/dist/errors.js.map +1 -1
- package/dist/flow-producer.d.ts.map +1 -1
- package/dist/flow-producer.js +5 -43
- package/dist/flow-producer.js.map +1 -1
- package/dist/functions/index.d.ts +50 -2
- package/dist/functions/index.d.ts.map +1 -1
- package/dist/functions/index.js +522 -82
- package/dist/functions/index.js.map +1 -1
- package/dist/graceful-shutdown.d.ts.map +1 -1
- package/dist/graceful-shutdown.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/job.d.ts +30 -0
- package/dist/job.d.ts.map +1 -1
- package/dist/job.js +127 -13
- package/dist/job.js.map +1 -1
- package/dist/queue-events.d.ts.map +1 -1
- package/dist/queue-events.js +12 -6
- package/dist/queue-events.js.map +1 -1
- package/dist/queue.d.ts +50 -2
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +297 -115
- package/dist/queue.js.map +1 -1
- package/dist/sandbox/index.d.ts +10 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +56 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/pool.d.ts +27 -0
- package/dist/sandbox/pool.d.ts.map +1 -0
- package/dist/sandbox/pool.js +273 -0
- package/dist/sandbox/pool.js.map +1 -0
- package/dist/sandbox/runner.d.ts +6 -0
- package/dist/sandbox/runner.d.ts.map +1 -0
- package/dist/sandbox/runner.js +154 -0
- package/dist/sandbox/runner.js.map +1 -0
- package/dist/sandbox/sandbox-job.d.ts +61 -0
- package/dist/sandbox/sandbox-job.d.ts.map +1 -0
- package/dist/sandbox/sandbox-job.js +137 -0
- package/dist/sandbox/sandbox-job.js.map +1 -0
- package/dist/sandbox/types.d.ts +59 -0
- package/dist/sandbox/types.d.ts.map +1 -0
- package/dist/sandbox/types.js +25 -0
- package/dist/sandbox/types.js.map +1 -0
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +35 -6
- package/dist/scheduler.js.map +1 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +9 -3
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +36 -2
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +180 -5
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +4 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +90 -23
- package/dist/utils.js.map +1 -1
- package/dist/worker.d.ts +14 -2
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +137 -18
- package/dist/worker.js.map +1 -1
- package/package.json +16 -3
- package/.env +0 -1
- package/.jules/bolt.md +0 -3
- package/demo/README.md +0 -169
- package/demo/dashboard-server.ts +0 -474
- package/demo/index.ts +0 -502
- package/demo/package-lock.json +0 -2051
- package/demo/package.json +0 -26
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to glide-mq are documented here.
|
|
4
|
+
|
|
5
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## [0.8.1] - 2026-02-27
|
|
14
|
+
|
|
15
|
+
### Security
|
|
16
|
+
|
|
17
|
+
- Reject invalid cron patterns: zero step (`*/0`), out-of-bounds values, reversed ranges, malformed tokens (#56).
|
|
18
|
+
- Enforce 1MB payload limit on job data, progress, and logs using `Buffer.byteLength` for correct UTF-8 byte counting. Covers `add`, `addBulk`, `updateData`, `updateProgress`, and `log` (#61).
|
|
19
|
+
- Fix path leak in sandbox error messages (#54).
|
|
20
|
+
|
|
21
|
+
### Performance
|
|
22
|
+
|
|
23
|
+
- Hierarchical cron search replacing brute-force minute iteration - 4400x speedup for yearly schedules. UTC-correct date handling, 10-year search horizon (#59).
|
|
24
|
+
- Batch Redis commands in `Job.retry()` and `updateProgress()` (#53).
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Comprehensive local fuzzer with pre-push hook.
|
|
29
|
+
|
|
30
|
+
### Docs
|
|
31
|
+
|
|
32
|
+
- Dashboard section in README, feature map improvements (#57, #58).
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## [0.8.0] - 2026-02-23
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- `queue.getJobScheduler(name)` - fetch a single scheduler entry by name. Returns `SchedulerEntry | null` with the schedule configuration (pattern/every), job template, and next run timestamp. Completes the scheduler API alongside `upsertJobScheduler`, `getRepeatableJobs`, and `removeJobScheduler` (#51).
|
|
41
|
+
- `queue.getWorkers()` - list all active workers for the queue. Returns `WorkerInfo[]` with id, addr (hostname), pid, startedAt, age (ms), and activeJobs count. Workers register with TTL-based heartbeat keys that auto-expire on crash (#49).
|
|
42
|
+
- `queue.drain(delayed?)` — remove all waiting jobs from the queue without touching active jobs. Pass `true` to also remove delayed/scheduled jobs. Implemented as a single Valkey Server Function call; emits a `'drained'` event (#41).
|
|
43
|
+
- `TestQueue.drain(delayed?)` — in-memory equivalent; removes waiting (and optionally delayed) jobs from `TestQueue`.
|
|
44
|
+
- `active` event on `Worker` and `TestWorker` — emitted with `(job, jobId)` when a job starts processing (#38).
|
|
45
|
+
- `drained` event on `Worker` and `TestWorker` — emitted when the queue transitions from non-empty to empty. A new `isDrained` flag prevents repeated emissions (#38).
|
|
46
|
+
- `queue.clean(grace, limit, type)` — bulk-remove old `completed` or `failed` jobs by minimum age. Returns an array of removed job IDs. Implemented as a single Valkey Server Function call (#39).
|
|
47
|
+
- `job.discard()` — immediately move an active job to failed state, bypassing retries (#40).
|
|
48
|
+
- `UnrecoverableError` — throw this error class inside a processor to skip all remaining retry attempts and fail the job permanently (#40).
|
|
49
|
+
- `job.changePriority(newPriority)` — re-prioritize a waiting, prioritized, or delayed job after enqueue. Setting priority to `0` moves it back to the normal stream. Throws if the job is active, completed, or failed (#43).
|
|
50
|
+
- `job.changeDelay(newDelay)` — mutate the fire time of a delayed job after enqueue. Setting delay to `0` promotes immediately (to waiting or prioritized depending on priority). Setting delay > 0 on a waiting or prioritized job moves it to the scheduled ZSet. Throws if the job is active, completed, or failed (#45).
|
|
51
|
+
- `job.promote()` — move a delayed job to waiting immediately. Always moves to the waiting stream regardless of priority (unlike `changeDelay(0)` which preserves priority scheduling). Priority metadata is kept in the job hash. Throws if the job is not in the delayed state (#46).
|
|
52
|
+
- `queue.retryJobs(opts?)` — bulk-retry failed jobs in a single Valkey Server Function call. Pass `{ count: N }` to limit the number of jobs retried, or omit to retry all. All retried jobs go to the scheduled ZSet (the promote cycle moves them to the stream). Returns the count of retried jobs (#47).
|
|
53
|
+
|
|
54
|
+
### Performance
|
|
55
|
+
|
|
56
|
+
- Batch `getChildrenValues` for O(1) network trips (#50).
|
|
57
|
+
- Batch scheduler operations into single pipeline RTT.
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- `job.retry()` — now removes the job from the failed ZSet before adding to scheduled, and resets `attemptsMade` and `finishedOn`.
|
|
62
|
+
- Sanitize stack traces in sandbox runner (#44).
|
|
63
|
+
- Replace hardcoded sleeps with `waitFor` in flaky CI tests (#48).
|
|
64
|
+
|
|
65
|
+
### Changed
|
|
66
|
+
|
|
67
|
+
- CI pipeline rewrite from scratch.
|
|
68
|
+
- ESLint + Prettier with TypeScript support.
|
|
69
|
+
- Prettier formatting applied to src/ and tests/.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## [0.7.0]
|
|
74
|
+
|
|
75
|
+
### Added
|
|
76
|
+
|
|
77
|
+
- Sandboxed processor: run worker processor in a child process or worker thread (`sandbox: {}` option). Protects the main process from processor crashes and memory leaks (#36).
|
|
78
|
+
- Sandbox pool stress tests (#37).
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
|
|
82
|
+
- Resolved 4 source bugs and 12 flaky test files (#34).
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## [0.6.0]
|
|
87
|
+
|
|
88
|
+
### Added
|
|
89
|
+
|
|
90
|
+
- Comprehensive README rewrite: star CTA, install command, expanded feature list, differentiators (#35).
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## [0.4.0]
|
|
95
|
+
|
|
96
|
+
Initial public release on npm.
|
|
97
|
+
|
|
98
|
+
- Valkey Server Functions for all queue operations (FUNCTION LOAD + FCALL).
|
|
99
|
+
- Hash-tagged keys for cluster compatibility.
|
|
100
|
+
- XREADGROUP + consumer groups + PEL for at-least-once delivery.
|
|
101
|
+
- `completeAndFetchNext` single-RTT job transition.
|
|
102
|
+
- FlowProducer workflows: `chain`, `group`, `chord`.
|
|
103
|
+
- Schedulers: cron and interval repeating jobs.
|
|
104
|
+
- Rate limiting, deduplication, compression, retries, DLQ.
|
|
105
|
+
- Per-key ordering, global concurrency, job revocation.
|
|
106
|
+
- QueueEvents stream-based lifecycle events.
|
|
107
|
+
- In-memory `TestQueue` and `TestWorker` (no Valkey needed).
|
|
108
|
+
- OpenTelemetry tracing, per-job logs.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2024-2026 Avi Fenesh
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,55 +1,43 @@
|
|
|
1
1
|
# glide-mq
|
|
2
2
|
|
|
3
|
-
High-performance message queue for Node.js — Streams
|
|
3
|
+
**High-performance message queue for Node.js** — powered by Valkey/Redis Streams and a Rust-native NAPI client.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
If you find this useful, [give it a ⭐ on GitHub](https://github.com/avifenesh/glide-mq) — it helps the project reach more developers.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
| Concurrency | Throughput |
|
|
12
|
-
|-------------|-----------|
|
|
13
|
-
| c=1 | 4,376 jobs/s |
|
|
14
|
-
| c=5 | 14,925 jobs/s |
|
|
15
|
-
| c=10 | 15,504 jobs/s |
|
|
16
|
-
| c=50 | 48,077 jobs/s |
|
|
17
|
-
|
|
18
|
-
### Bulk add (`addBulk` via Batch API)
|
|
19
|
-
|
|
20
|
-
| Jobs | Serial | Batch | Speedup |
|
|
21
|
-
|------|--------|-------|---------|
|
|
22
|
-
| 200 | 76ms | 14ms | 5.4x |
|
|
23
|
-
| 1,000 | 228ms | 18ms | 12.7x |
|
|
24
|
-
|
|
25
|
-
### Payload compression
|
|
7
|
+
```bash
|
|
8
|
+
npm install glide-mq
|
|
9
|
+
```
|
|
26
10
|
|
|
27
|
-
|
|
28
|
-
|------|--------------------------|---------|
|
|
29
|
-
| Plain | 15,327 bytes | — |
|
|
30
|
-
| Gzip | 331 bytes | 98% |
|
|
11
|
+
## Why glide-mq
|
|
31
12
|
|
|
32
|
-
|
|
13
|
+
- **1 RTT per job** — `completeAndFetchNext` finishes the current job and fetches the next one in a single round-trip
|
|
14
|
+
- **Rust core, not ioredis** — built on [Valkey GLIDE](https://github.com/valkey-io/valkey-glide)'s native NAPI bindings for lower latency and less GC pressure
|
|
15
|
+
- **1 function library, not 53 scripts** — all queue logic runs as a single Valkey Server Function (no EVAL overhead)
|
|
16
|
+
- **Cluster-native** — hash-tagged keys work out of the box; no manual `{braces}` needed
|
|
17
|
+
- **Cloud-ready** — AZ-affinity routing and IAM auth built in
|
|
33
18
|
|
|
34
|
-
##
|
|
19
|
+
## Features
|
|
35
20
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
| RTT per job | 1 (`completeAndFetchNext`) | 2+ |
|
|
41
|
-
| Cluster support | Built-in hash tags | Afterthought `{braces}` |
|
|
42
|
-
| Client | NAPI Rust core | ioredis |
|
|
43
|
-
| AZ-Affinity | ✓ | ✗ |
|
|
44
|
-
| IAM auth | ✓ | ✗ |
|
|
21
|
+
### Core queueing
|
|
22
|
+
- **Queues & Workers** — producer/consumer with configurable concurrency ([Usage](docs/USAGE.md#queue), [Demo](demo/README.md#demo-scenarios))
|
|
23
|
+
- **Delayed, priority, and batch jobs** — schedule jobs, prioritize critical work, and ingest at high throughput with `addBulk` ([Usage](docs/USAGE.md#queue), [Demo](demo/README.md#demo-scenarios))
|
|
24
|
+
- **Job search & progress tracking** — query by state/name/data and stream progress updates ([Usage](docs/USAGE.md#worker), [Search tests](tests/search.test.ts))
|
|
45
25
|
|
|
46
|
-
|
|
26
|
+
### Reliability & control
|
|
27
|
+
- **Retries, backoff, and DLQ** — exponential/fixed/custom retries with dead-letter queues ([Advanced](docs/ADVANCED.md#retries-and-backoff), [Demo](demo/README.md#demo-scenarios))
|
|
28
|
+
- **Stalled recovery, pause/resume, and drain** — auto-reclaim stuck jobs, pause processing, and server-side drain waiting/delayed jobs ([Usage](docs/USAGE.md#worker), [Demo](demo/README.md#api-endpoints-dashboard-server))
|
|
29
|
+
- **Job revocation + sandboxed processors** — cooperative cancellation and isolated file-based processors in worker threads/child processes ([Advanced](docs/ADVANCED.md#job-revocation), [Architecture](docs/ARCHITECTURE.md#typescript-api), [Sandbox example](tests/sandbox-integration.test.ts))
|
|
47
30
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
31
|
+
### Orchestration & scheduling
|
|
32
|
+
- **Workflows** — `FlowProducer` parent-child trees and `chain`/`group`/`chord` helpers ([Workflows](docs/WORKFLOWS.md), [Demo](demo/README.md#demo-scenarios))
|
|
33
|
+
- **Schedulers** — cron and interval repeatable jobs persisted across restarts ([Advanced](docs/ADVANCED.md#job-schedulers), [Demo](demo/README.md#demo-scenarios))
|
|
34
|
+
- **Per-key ordering, global concurrency, and rate limiting** — deterministic ordering with queue-wide and token-bucket controls ([Advanced](docs/ADVANCED.md#ordering-and-group-concurrency), [Advanced](docs/ADVANCED.md#global-concurrency), [Advanced](docs/ADVANCED.md#global-rate-limiting))
|
|
35
|
+
- **Deduplication** — simple, throttle, and debounce modes with TTL ([Advanced](docs/ADVANCED.md#deduplication), [Demo](demo/README.md#demo-scenarios))
|
|
51
36
|
|
|
52
|
-
|
|
37
|
+
### Observability, ops, and testing
|
|
38
|
+
- **QueueEvents, metrics, logs, and dashboard** — real-time events + OpenTelemetry + [`@glidemq/dashboard`](https://github.com/avifenesh/glidemq-dashboard) ([Observability](docs/OBSERVABILITY.md), [Dashboard demo API](demo/dashboard-server.ts))
|
|
39
|
+
- **Compression, graceful shutdown, and shared connections** — lower payload size and easier process lifecycle management ([Advanced](docs/ADVANCED.md#transparent-compression), [Usage](docs/USAGE.md#graceful-shutdown), [Advanced](docs/ADVANCED.md#shared-client))
|
|
40
|
+
- **In-memory testing mode** — `TestQueue` and `TestWorker` with zero Valkey dependency ([Testing](docs/TESTING.md), [Testing-mode test](tests/testing-mode.test.ts))
|
|
53
41
|
|
|
54
42
|
## Quick Start
|
|
55
43
|
|
|
@@ -72,14 +60,58 @@ worker.on('completed', (job) => console.log(`Job ${job.id} done`));
|
|
|
72
60
|
worker.on('failed', (job, err) => console.error(`Job ${job.id} failed:`, err.message));
|
|
73
61
|
```
|
|
74
62
|
|
|
63
|
+
Requires Node.js 20+ and a running [Valkey](https://valkey.io) (7.0+) or Redis 7.0+ instance.
|
|
64
|
+
|
|
65
|
+
## Benchmarks
|
|
66
|
+
|
|
67
|
+
| Concurrency | Throughput |
|
|
68
|
+
|-------------|-----------|
|
|
69
|
+
| c=1 | 4,376 jobs/s |
|
|
70
|
+
| c=5 | 14,925 jobs/s |
|
|
71
|
+
| c=10 | 15,504 jobs/s |
|
|
72
|
+
| c=50 | 48,077 jobs/s |
|
|
73
|
+
|
|
74
|
+
`addBulk` batch API: **1,000 jobs in 18 ms** (12.7× faster than serial).
|
|
75
|
+
Gzip compression: **98% payload reduction** on 15 KB payloads.
|
|
76
|
+
|
|
77
|
+
*Valkey 8.0, single node, no-op processor. Run `npm run bench` to reproduce.*
|
|
78
|
+
|
|
79
|
+
## Dashboard
|
|
80
|
+
|
|
81
|
+
[`@glidemq/dashboard`](https://github.com/avifenesh/glidemq-dashboard) - web UI for monitoring and managing queues in real time.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm install @glidemq/dashboard
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { createDashboard } from '@glidemq/dashboard';
|
|
89
|
+
|
|
90
|
+
app.use('/dashboard', createDashboard([queue1, queue2], {
|
|
91
|
+
// readOnly: true,
|
|
92
|
+
// authorize: (req, action) => checkSession(req),
|
|
93
|
+
}));
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Workers, job schedulers, DLQ, metrics, search, bulk actions (drain, retry, clean) - all from the browser. See the [dashboard repo](https://github.com/avifenesh/glidemq-dashboard) for full docs.
|
|
97
|
+
|
|
75
98
|
## Documentation
|
|
76
99
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
100
|
+
| Guide | What you'll learn | Related examples |
|
|
101
|
+
|-------|-------------------|------------------|
|
|
102
|
+
| [Usage](docs/USAGE.md) | Queue & Worker basics, graceful shutdown, cluster mode | [Demo scenarios](demo/README.md#demo-scenarios) |
|
|
103
|
+
| [Advanced](docs/ADVANCED.md) | Schedulers, rate limiting, dedup, compression, retries & DLQ | [Comprehensive demo app](demo/index.ts) |
|
|
104
|
+
| [Workflows](docs/WORKFLOWS.md) | FlowProducer, `chain`, `group`, `chord` pipelines | [Workflow scenarios](demo/README.md#demo-scenarios) |
|
|
105
|
+
| [Observability](docs/OBSERVABILITY.md) | OpenTelemetry, job logs, `@glidemq/dashboard` | [Dashboard API server](demo/dashboard-server.ts) |
|
|
106
|
+
| [Testing](docs/TESTING.md) | In-memory `TestQueue` & `TestWorker` — no Valkey needed | [Testing mode test](tests/testing-mode.test.ts) |
|
|
107
|
+
| [Architecture](docs/ARCHITECTURE.md) | Key design, Valkey functions, data layout | [Architecture validation tests](tests/review-coverage.test.ts) |
|
|
108
|
+
| [Migration](docs/MIGRATION.md) | Coming from BullMQ? API mapping & workarounds | [Compatibility suites](tests/compat-bull.test.ts) |
|
|
109
|
+
|
|
110
|
+
## Get Involved
|
|
111
|
+
|
|
112
|
+
- ⭐ [Star on GitHub](https://github.com/avifenesh/glide-mq) — helps others find the project
|
|
113
|
+
- 🐛 [Open an issue](https://github.com/avifenesh/glide-mq/issues) — bug reports & feature requests welcome
|
|
114
|
+
- 💬 [Discussions](https://github.com/avifenesh/glide-mq/discussions) — questions, ideas, show & tell
|
|
83
115
|
|
|
84
116
|
## License
|
|
85
117
|
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAkB,MAAM,SAAS,CAAC;AA4BzE;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoB3E;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAkB,MAAM,SAAS,CAAC;AA4BzE;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoB3E;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAKvD;AAID;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,EACd,aAAa,GAAE,MAAuB,EACtC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,aAAa,GAAE,MAAuB,EACtC,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
package/dist/connection.js
CHANGED
|
@@ -70,8 +70,7 @@ function isClusterClient(client) {
|
|
|
70
70
|
return true;
|
|
71
71
|
// Duck-type fallback: GlideClusterClient has scan(ClusterScanCursor, ...) signature
|
|
72
72
|
// while GlideClient has scan(cursor: string, ...) - check for cluster-specific method
|
|
73
|
-
return typeof client.clusterScan === 'function'
|
|
74
|
-
|| client.constructor?.name === 'GlideClusterClient';
|
|
73
|
+
return typeof client.clusterScan === 'function' || client.constructor?.name === 'GlideClusterClient';
|
|
75
74
|
}
|
|
76
75
|
const _libraryLoadPromises = new WeakMap();
|
|
77
76
|
/**
|
|
@@ -123,7 +122,10 @@ async function ensureFunctionLibrary(client, librarySource = index_1.LIBRARY_SOU
|
|
|
123
122
|
}
|
|
124
123
|
catch (err) {
|
|
125
124
|
const msg = err instanceof Error ? err.message : String(err);
|
|
126
|
-
if (!msg.includes('Function not loaded') &&
|
|
125
|
+
if (!msg.includes('Function not loaded') &&
|
|
126
|
+
!msg.includes('Function not found') &&
|
|
127
|
+
!msg.includes('No matching script') &&
|
|
128
|
+
!msg.includes('NOSCRIPT')) {
|
|
127
129
|
throw err;
|
|
128
130
|
}
|
|
129
131
|
}
|
package/dist/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;AAiCA,oCAoBC;AAMD,oDAEC;AAOD,
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"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"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -7,4 +7,7 @@ export declare class ConnectionError extends GlideMQError {
|
|
|
7
7
|
export declare class ScriptError extends GlideMQError {
|
|
8
8
|
constructor(message: string);
|
|
9
9
|
}
|
|
10
|
+
export declare class UnrecoverableError extends GlideMQError {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
10
13
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAC/B,OAAO,EAAE,MAAM;CAI5B"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ScriptError = exports.ConnectionError = exports.GlideMQError = void 0;
|
|
3
|
+
exports.UnrecoverableError = exports.ScriptError = exports.ConnectionError = exports.GlideMQError = void 0;
|
|
4
4
|
class GlideMQError extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
@@ -22,4 +22,11 @@ class ScriptError extends GlideMQError {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
exports.ScriptError = ScriptError;
|
|
25
|
+
class UnrecoverableError extends GlideMQError {
|
|
26
|
+
constructor(message) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = 'UnrecoverableError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.UnrecoverableError = UnrecoverableError;
|
|
25
32
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED,MAAa,eAAgB,SAAQ,YAAY;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,MAAa,WAAY,SAAQ,YAAY;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AALD,kCAKC"}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED,MAAa,eAAgB,SAAQ,YAAY;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,MAAa,WAAY,SAAQ,YAAY;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AALD,kCAKC;AAED,MAAa,kBAAmB,SAAQ,YAAY;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-producer.d.ts","sourceRoot":"","sources":["../src/flow-producer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAU,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAO5B,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,OAAO,CAAS;gBAEZ,IAAI,EAAE,mBAAmB;IAOrC,gBAAgB;YACF,SAAS;
|
|
1
|
+
{"version":3,"file":"flow-producer.d.ts","sourceRoot":"","sources":["../src/flow-producer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAU,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAO5B,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,OAAO,CAAS;gBAEZ,IAAI,EAAE,mBAAmB;IAOrC,gBAAgB;YACF,SAAS;IAoBvB;;;;OAIG;IACG,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAe1C;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IASnD;;;;OAIG;YACW,gBAAgB;IA8I9B;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAU7B"}
|
package/dist/flow-producer.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.FlowProducer = void 0;
|
|
37
4
|
const job_1 = require("./job");
|
|
@@ -59,8 +26,7 @@ class FlowProducer {
|
|
|
59
26
|
if (!this.client) {
|
|
60
27
|
if (this.opts.client) {
|
|
61
28
|
const injected = this.opts.client;
|
|
62
|
-
const clusterMode = this.opts.connection?.clusterMode
|
|
63
|
-
?? (0, connection_1.isClusterClient)(injected);
|
|
29
|
+
const clusterMode = this.opts.connection?.clusterMode ?? (0, connection_1.isClusterClient)(injected);
|
|
64
30
|
await (0, connection_1.ensureFunctionLibraryOnce)(injected, index_1.LIBRARY_SOURCE, clusterMode);
|
|
65
31
|
this.client = injected;
|
|
66
32
|
this.clientOwned = false;
|
|
@@ -110,23 +76,19 @@ class FlowProducer {
|
|
|
110
76
|
const parentKeys = (0, utils_1.buildKeys)(parentQueueName, prefix);
|
|
111
77
|
// If no children, this is a leaf - add as a regular job (not a flow)
|
|
112
78
|
if (!flow.children || flow.children.length === 0) {
|
|
113
|
-
const { addJob } = await Promise.resolve().then(() => __importStar(require('./functions/index')));
|
|
114
79
|
const timestamp = Date.now();
|
|
115
80
|
const opts = flow.opts ?? {};
|
|
116
81
|
const groupRateMax = opts.ordering?.rateLimit?.max ?? 0;
|
|
117
82
|
const groupRateDuration = opts.ordering?.rateLimit?.duration ?? 0;
|
|
118
|
-
const tbCapacity = opts.ordering?.tokenBucket
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
? Math.round(opts.ordering.tokenBucket.refillRate * 1000) : 0;
|
|
122
|
-
const jobCost = opts.cost != null
|
|
123
|
-
? Math.round(opts.cost * 1000) : 0;
|
|
83
|
+
const tbCapacity = opts.ordering?.tokenBucket ? Math.round(opts.ordering.tokenBucket.capacity * 1000) : 0;
|
|
84
|
+
const tbRefillRate = opts.ordering?.tokenBucket ? Math.round(opts.ordering.tokenBucket.refillRate * 1000) : 0;
|
|
85
|
+
const jobCost = opts.cost != null ? Math.round(opts.cost * 1000) : 0;
|
|
124
86
|
let groupConcurrency = opts.ordering?.concurrency ?? 0;
|
|
125
87
|
// Force group path when rate limit or token bucket is set
|
|
126
88
|
if ((groupRateMax > 0 || tbCapacity > 0) && groupConcurrency < 1) {
|
|
127
89
|
groupConcurrency = 1;
|
|
128
90
|
}
|
|
129
|
-
const jobId = await addJob(client, parentKeys, flow.name, JSON.stringify(flow.data), JSON.stringify(opts), timestamp, opts.delay ?? 0, opts.priority ?? 0, '', opts.attempts ?? 0, opts.ordering?.key ?? '', groupConcurrency, groupRateMax, groupRateDuration, tbCapacity, tbRefillRate, jobCost);
|
|
91
|
+
const jobId = await (0, index_1.addJob)(client, parentKeys, flow.name, JSON.stringify(flow.data), JSON.stringify(opts), timestamp, opts.delay ?? 0, opts.priority ?? 0, '', opts.attempts ?? 0, opts.ordering?.key ?? '', groupConcurrency, groupRateMax, groupRateDuration, tbCapacity, tbRefillRate, jobCost);
|
|
130
92
|
if (String(jobId) === 'ERR:COST_EXCEEDS_CAPACITY') {
|
|
131
93
|
throw new Error('Job cost exceeds token bucket capacity');
|
|
132
94
|
}
|