bullpane 0.6.2 → 0.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.
@@ -16,6 +16,7 @@
16
16
  ARGV[2] number of metric points (newest N minutes)
17
17
  ARGV[3] window start (unix ms) for the success/failure rate ZCOUNTs
18
18
  ARGV[4] `${prefix}:${queue}:` (to read a job's opts and detect retention)
19
+ ARGV[5] max groups whose waiting jobs are summed into [22]; 0 = skip (lists)
19
20
 
20
21
  Returns a flat array:
21
22
  [1..8] counts (LLEN for lists, ZCARD for zsets)
@@ -37,6 +38,10 @@
37
38
  in the same EVALSHA (no extra round trip to Redis). Worth the budget
38
39
  because it is the only way for the `active` tab to say "3 of these hung";
39
40
  without it the operator sees "active 8" and cannot tell half are dead.
41
+ [22] BullMQ Pro: jobs waiting in groups (each group's list + its prioritized
42
+ zset), summed over at most ARGV[5] groups. Pro keeps them there, not in
43
+ `wait`, so [1] alone says 0 for a Pro queue full of grouped jobs.
44
+ [23] how many groups were summed into [22]; fewer than [11] = partial sum.
40
45
 
41
46
  Cluster safe: every key belongs to the same queue (same hash tag).
42
47
  Read only: the legacy "0:" wait-list marker is skipped, never popped.
@@ -137,4 +142,25 @@ out[20] = rcall("ZCARD", KEYS[15])
137
142
  -- hung. SCARD is O(1), so the count rides along for free in this script.
138
143
  out[21] = rcall("SCARD", KEYS[16])
139
144
 
145
+ -- Waiting jobs of BullMQ Pro groups: two O(1) commands per group (LLEN + ZCARD),
146
+ -- walking the four status zsets in Pro's order and stopping at ARGV[5] groups, so
147
+ -- the cost is bounded however many groups a queue has. Only the single-queue page
148
+ -- asks (ARGV[5] = 0 everywhere else), and only a queue with groups pays.
149
+ local groupWaiting, groupsSummed = 0, 0
150
+ local maxGroups = tonumber(ARGV[5]) or 0
151
+ if maxGroups > 0 and groupsCount > 0 then
152
+ local statusKeys = { KEYS[10], ARGV[4] .. "groups:limit", ARGV[4] .. "groups:max", ARGV[4] .. "groups:paused" }
153
+ for _, statusKey in ipairs(statusKeys) do
154
+ local left = maxGroups - groupsSummed
155
+ if left <= 0 then break end
156
+ for _, gid in ipairs(rcall("ZRANGE", statusKey, 0, left - 1)) do
157
+ local groupKey = ARGV[4] .. "groups:" .. gid
158
+ groupWaiting = groupWaiting + rcall("LLEN", groupKey) + rcall("ZCARD", groupKey .. ":p")
159
+ groupsSummed = groupsSummed + 1
160
+ end
161
+ end
162
+ end
163
+ out[22] = groupWaiting
164
+ out[23] = groupsSummed
165
+
140
166
  return out