zizq 0.3.7 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3252547a350b856e8122d15a77275769f62a4495efe36b36e252eba2246b51cf
4
- data.tar.gz: 570e3ef065cbe42cfc038d6c1dd6669940d62f051d53965c48bea548f329e941
3
+ metadata.gz: 424b67e8dbba3c82506c24ed18cbaa9fc87af3febe9e079ef458f705e9299fdd
4
+ data.tar.gz: 53bc5f8b3aefbdddc69e2471e6efbd2ba7c84016cb8eb63ff16bc463107991fe
5
5
  SHA512:
6
- metadata.gz: 545bc4510f7df1acc51817c48ec2fae04c3a96df3589c2e3f12017d8bebb311a69cd7d18b14941ed3206829d08dd1cf28dd1d0461d44c7d2a265eead57f70710
7
- data.tar.gz: 00b8916adf6921aded73d0f16cde1c2c52c98f338b3a9e4ad79a4131f06aef42b4001623c2e43d53a7c9d67e289c62f97b6abfbee6b0bb240ed89726e273ae7e
6
+ metadata.gz: 10f7ab3fe215f04eff3c1753826734c609454c93f9c30c586dd0f38f49ac563d23dcb47317c12e7c00cde3dff558cb124ce0ae25a3c801b9b71a85ce806d96e9
7
+ data.tar.gz: 422601a65e9862a73360e036a0e5f44ac36bdcaa04a3fe585567e4fefaf9b73e4fa4736ac3fe9d0cc552173bcd9c47fef98cbc1a6935ef3a64870a839a5a13b9
data/README.md CHANGED
@@ -33,13 +33,13 @@ API.
33
33
  Add it to your application's `Gemfile`:
34
34
 
35
35
  ```ruby
36
- gem 'zizq', '~> 0.3.7'
36
+ gem 'zizq', '~> 0.5.0'
37
37
  ```
38
38
 
39
39
  Or install it manually:
40
40
 
41
41
  ```shell
42
- $ gem install zizq -v 0.3.7
42
+ $ gem install zizq -v 0.5.0
43
43
  ```
44
44
 
45
45
  Ruby **3.2.8 or newer** is required. Client and server share version
data/lib/zizq/client.rb CHANGED
@@ -238,11 +238,17 @@ module Zizq
238
238
  # The `filter` parameter accepts a jq expression for filtering jobs by
239
239
  # payload content (e.g. `.user_id == 42`).
240
240
  #
241
+ # Range filters (`priority`, `attempts`, `ready_at`) accept exact values or
242
+ # inclusive ranges.
243
+ #
241
244
  # @rbs id: (String | Array[String])?
242
245
  # @rbs status: (String | Array[String])?
243
246
  # @rbs queue: (String | Array[String])?
244
247
  # @rbs type: (String | Array[String])?
245
248
  # @rbs filter: String?
249
+ # @rbs priority: (Integer | Range[Integer?])?
250
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
251
+ # @rbs attempts: (Integer | Range[Integer?])?
246
252
  # @rbs from: String?
247
253
  # @rbs order: Zizq::sort_direction?
248
254
  # @rbs limit: Integer?
@@ -252,10 +258,25 @@ module Zizq
252
258
  queue: nil,
253
259
  type: nil,
254
260
  filter: nil,
261
+ priority: nil,
262
+ ready_at: nil,
263
+ attempts: nil,
255
264
  from: nil,
256
265
  order: nil,
257
266
  limit: nil)
258
- options = { id:, status:, queue:, type:, filter:, from:, order:, limit: }.compact #: Hash[Symbol, untyped]
267
+ options = {
268
+ id:,
269
+ status:,
270
+ queue:,
271
+ type:,
272
+ filter:,
273
+ priority: encode_range(priority),
274
+ ready_at: encode_range(ready_at) { |v| (v.to_f * 1000).to_i },
275
+ attempts: encode_range(attempts),
276
+ from:,
277
+ order:,
278
+ limit:,
279
+ }.compact #: Hash[Symbol, untyped]
259
280
 
260
281
  multi_keys = %i[id status queue type]
261
282
  params = build_where_params(options, multi_keys:)
@@ -280,13 +301,28 @@ module Zizq
280
301
  # @rbs queue: (String | Array[String])?
281
302
  # @rbs type: (String | Array[String])?
282
303
  # @rbs filter: String?
304
+ # @rbs priority: (Integer | Range[Integer?])?
305
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
306
+ # @rbs attempts: (Integer | Range[Integer?])?
283
307
  # @rbs return: Integer
284
308
  def count_jobs(id: nil,
285
309
  status: nil,
286
310
  queue: nil,
287
311
  type: nil,
288
- filter: nil)
289
- options = { id:, status:, queue:, type:, filter: }.compact #: Hash[Symbol, untyped]
312
+ filter: nil,
313
+ priority: nil,
314
+ ready_at: nil,
315
+ attempts: nil)
316
+ options = {
317
+ id:,
318
+ status:,
319
+ queue:,
320
+ type:,
321
+ filter:,
322
+ priority: encode_range(priority),
323
+ ready_at: encode_range(ready_at) { |v| (v.to_f * 1000).to_i },
324
+ attempts: encode_range(attempts),
325
+ }.compact #: Hash[Symbol, untyped]
290
326
 
291
327
  multi_keys = %i[id status queue type]
292
328
  params = build_where_params(options, multi_keys:)
@@ -336,6 +372,26 @@ module Zizq
336
372
  data.fetch("deleted")
337
373
  end
338
374
 
375
+ # Wipe *every* cron group and *every* job on the server.
376
+ #
377
+ # Equivalent to calling `delete_all_crons` followed by
378
+ # `delete_all_jobs` (no filter), but in a single request. Useful
379
+ # primarily as a setup/teardown step in tests where you want a
380
+ # known-empty server between scenarios.
381
+ #
382
+ # **Destructive.** No filters, no escape hatch, no confirmation —
383
+ # the server-side operation simply returns once everything is gone.
384
+ #
385
+ # Named `erase_all_data` rather than `reset` because `Zizq.reset!`
386
+ # already exists at the module level for client-side SDK state.
387
+ #
388
+ # @rbs return: void
389
+ def erase_all_data
390
+ response = raw_post("/reset")
391
+ handle_response!(response, expected: 204)
392
+ nil
393
+ end
394
+
339
395
  # Update a single job's mutable fields.
340
396
  #
341
397
  # Fields not provided are left unchanged. Use `Zizq::RESET` to clear
@@ -360,8 +416,12 @@ module Zizq
360
416
  backoff: UNCHANGED,
361
417
  retention: UNCHANGED)
362
418
  body = build_set_body(
363
- queue:, priority:, ready_at:,
364
- retry_limit:, backoff:, retention:
419
+ queue:,
420
+ priority:,
421
+ ready_at:,
422
+ retry_limit:,
423
+ backoff:,
424
+ retention:
365
425
  )
366
426
  response = patch("/jobs/#{enc(id)}", body)
367
427
  data = handle_response!(response, expected: 200)
@@ -502,6 +562,23 @@ module Zizq
502
562
  nil
503
563
  end
504
564
 
565
+ # Delete every cron group on the server in a single call.
566
+ #
567
+ # Returns the number of cron groups removed.
568
+ #
569
+ # **Destructive.** This deletes *every cron group on the server*.
570
+ # For granular deletes, use `delete_cron_group` with a specific
571
+ # name.
572
+ #
573
+ # Requires a Pro license on the server.
574
+ #
575
+ # @rbs return: Integer
576
+ def delete_all_crons
577
+ response = delete("/crons")
578
+ data = handle_response!(response, expected: 200)
579
+ data.fetch("deleted")
580
+ end
581
+
505
582
  # Fetch a single cron entry.
506
583
  #
507
584
  # @rbs group: String
@@ -889,9 +966,62 @@ module Zizq
889
966
  # @rbs queue: (String | Array[String])?
890
967
  # @rbs type: (String | Array[String])?
891
968
  # @rbs filter: String?
969
+ # @rbs priority: (Integer | Range[Integer?])?
970
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
971
+ # @rbs attempts: (Integer | Range[Integer?])?
892
972
  # @rbs return: Hash[Symbol, untyped]
893
- def validate_where(id: nil, status: nil, queue: nil, type: nil, filter: nil)
894
- { id:, status:, queue:, type:, filter: }.compact
973
+ def validate_where(id: nil,
974
+ status: nil,
975
+ queue: nil,
976
+ type: nil,
977
+ filter: nil,
978
+ priority: nil,
979
+ ready_at: nil,
980
+ attempts: nil)
981
+ {
982
+ id:,
983
+ status:,
984
+ queue:,
985
+ type:,
986
+ filter:,
987
+ priority: encode_range(priority),
988
+ ready_at: encode_range(ready_at) { |v| (v.to_f * 1000).to_i },
989
+ attempts: encode_range(attempts),
990
+ }.compact
991
+ end
992
+
993
+ # Encode an Integer or Range filter into the server's query format.
994
+ #
995
+ # Accepted shapes:
996
+ #
997
+ # - `nil` -> `nil` (no filter sent)
998
+ # - `Integer` -> `"N"` (single value)
999
+ # - `(a..b)` -> `"A..B"` (inclusive both ends)
1000
+ # - `(a..)` -> `"A.."` (lower bound only)
1001
+ # - `(..b)` -> `"..B"` (upper bound only)
1002
+ #
1003
+ # Exclusive ranges (`a...b`, `a...`, `...b`) raise `ArgumentError` — the
1004
+ # server only supports inclusive bounds. A bound transformation block can
1005
+ # convert values before formatting (e.g. seconds -> ms for `ready_at`).
1006
+ #
1007
+ # @rbs value: untyped
1008
+ # @rbs &block: ?(untyped) -> Integer
1009
+ # @rbs return: String?
1010
+ def encode_range(value, &block)
1011
+ block ||= ->(v) { v.to_i }
1012
+
1013
+ case value
1014
+ when nil
1015
+ nil
1016
+ when Range
1017
+ if value.exclude_end?
1018
+ raise ArgumentError,
1019
+ "exclusive ranges are not supported by the server; use an inclusive range (a..b) instead"
1020
+ end
1021
+ "#{value.begin&.then(&block)}..#{value.end&.then(&block)}"
1022
+ else
1023
+ block.call(value).to_s
1024
+ end
895
1025
  end
896
1026
 
897
1027
  # Validate set parameters via keyword args (rejects unknown keys) and
data/lib/zizq/query.rb CHANGED
@@ -55,6 +55,9 @@ module Zizq
55
55
  # @rbs type: (String | Array[String])?
56
56
  # @rbs status: (String | Array[String])?
57
57
  # @rbs jq_filter: String?
58
+ # @rbs priority: (Integer | Range[Integer?])?
59
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
60
+ # @rbs attempts: (Integer | Range[Integer?])?
58
61
  # @rbs order: Zizq::sort_direction?
59
62
  # @rbs limit: Integer?
60
63
  # @rbs page_size: Integer?
@@ -64,6 +67,9 @@ module Zizq
64
67
  type: nil,
65
68
  status: nil,
66
69
  jq_filter: nil,
70
+ priority: nil,
71
+ ready_at: nil,
72
+ attempts: nil,
67
73
  order: nil,
68
74
  limit: nil,
69
75
  page_size: nil)
@@ -72,6 +78,9 @@ module Zizq
72
78
  @type = type
73
79
  @status = status
74
80
  @jq_filter = jq_filter
81
+ @priority = priority
82
+ @ready_at = ready_at
83
+ @attempts = attempts
75
84
  @order = order
76
85
  @limit = limit
77
86
  @page_size = page_size
@@ -153,6 +162,62 @@ module Zizq
153
162
  rebuild(status: Array(@status) + Array(status))
154
163
  end
155
164
 
165
+ # Filter by priority range (replaces any existing priority filter).
166
+ #
167
+ # Accepts an Integer (exact match) or an inclusive Range. Lower numbers
168
+ # are higher priority. Exclusive ranges (e.g. `0...100`) raise
169
+ # `ArgumentError` — the server only supports inclusive bounds.
170
+ #
171
+ # Examples:
172
+ #
173
+ # .by_priority(50) # exactly priority 50
174
+ # .by_priority(0..100) # between 0 and 100 inclusive
175
+ # .by_priority(100..) # 100 or greater
176
+ # .by_priority(..100) # 100 or less
177
+ #
178
+ # @rbs priority: (Integer | Range[Integer?])?
179
+ # @rbs return: Query
180
+ def by_priority(priority)
181
+ rebuild(priority:)
182
+ end
183
+
184
+ # Filter by `ready_at` range (replaces any existing `ready_at` filter).
185
+ #
186
+ # Accepts a value (`Time`, `Numeric`, anything that responds to `to_f`)
187
+ # for an exact match, or an inclusive Range. Values are interpreted as
188
+ # fractional seconds on the Ruby side and converted to milliseconds for
189
+ # the server. Exclusive ranges raise `ArgumentError`.
190
+ #
191
+ # Examples:
192
+ #
193
+ # .by_ready_at(Time.now..) # ready to run now or later
194
+ # .by_ready_at(..Time.now) # was ready to run by now
195
+ # .by_ready_at(t1..t2) # ready between t1 and t2
196
+ #
197
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
198
+ # @rbs return: Query
199
+ def by_ready_at(ready_at)
200
+ rebuild(ready_at:)
201
+ end
202
+
203
+ # Filter by `attempts` range (replaces any existing `attempts` filter).
204
+ #
205
+ # Accepts an Integer (exact match) or an inclusive Range. `attempts` is
206
+ # the number of times the job has failed. Exclusive ranges raise
207
+ # `ArgumentError`.
208
+ #
209
+ # Examples:
210
+ #
211
+ # .by_attempts(0) # never failed
212
+ # .by_attempts(1..) # has failed at least once
213
+ # .by_attempts(1..3) # has failed 1, 2, or 3 times
214
+ #
215
+ # @rbs attempts: (Integer | Range[Integer?])?
216
+ # @rbs return: Query
217
+ def by_attempts(attempts)
218
+ rebuild(attempts:)
219
+ end
220
+
156
221
  # Filter by job class and exact arguments.
157
222
  #
158
223
  # The job class must include `Zizq::Job` or for Active Job classes must
@@ -304,6 +369,9 @@ module Zizq
304
369
  type: @type,
305
370
  status: @status,
306
371
  filter: @jq_filter,
372
+ priority: @priority,
373
+ ready_at: @ready_at,
374
+ attempts: @attempts,
307
375
  )
308
376
 
309
377
  @limit ? [total, @limit].min : total
@@ -421,6 +489,9 @@ module Zizq
421
489
  type: @type,
422
490
  status: @status,
423
491
  filter: @jq_filter,
492
+ priority: @priority,
493
+ ready_at: @ready_at,
494
+ attempts: @attempts,
424
495
  limit: [@page_size, @limit, (@page_size || @limit) && MAX_PAGE_SIZE].compact.min,
425
496
  order: @order,
426
497
  )
@@ -470,6 +541,9 @@ module Zizq
470
541
  type: @type,
471
542
  status: @status,
472
543
  filter: @jq_filter,
544
+ priority: @priority,
545
+ ready_at: @ready_at,
546
+ attempts: @attempts,
473
547
  }
474
548
 
475
549
  apply = {
@@ -527,6 +601,9 @@ module Zizq
527
601
  type: @type,
528
602
  status: @status,
529
603
  filter: @jq_filter,
604
+ priority: @priority,
605
+ ready_at: @ready_at,
606
+ attempts: @attempts,
530
607
  }
531
608
 
532
609
  if @limit || @page_size
@@ -564,6 +641,9 @@ module Zizq
564
641
  type: @type,
565
642
  status: @status,
566
643
  jq_filter: @jq_filter,
644
+ priority: @priority,
645
+ ready_at: @ready_at,
646
+ attempts: @attempts,
567
647
  order: @order,
568
648
  limit: @limit,
569
649
  page_size: @page_size)
@@ -573,6 +653,9 @@ module Zizq
573
653
  type:,
574
654
  status:,
575
655
  jq_filter:,
656
+ priority:,
657
+ ready_at:,
658
+ attempts:,
576
659
  limit:,
577
660
  order:,
578
661
  page_size:,
data/lib/zizq/version.rb CHANGED
@@ -5,5 +5,5 @@
5
5
  # frozen_string_literal: true
6
6
 
7
7
  module Zizq
8
- VERSION = "0.3.7" #: String
8
+ VERSION = "0.5.0" #: String
9
9
  end
@@ -105,16 +105,22 @@ module Zizq
105
105
  # The `filter` parameter accepts a jq expression for filtering jobs by
106
106
  # payload content (e.g. `.user_id == 42`).
107
107
  #
108
+ # Range filters (`priority`, `attempts`, `ready_at`) accept exact values or
109
+ # inclusive ranges.
110
+ #
108
111
  # @rbs id: (String | Array[String])?
109
112
  # @rbs status: (String | Array[String])?
110
113
  # @rbs queue: (String | Array[String])?
111
114
  # @rbs type: (String | Array[String])?
112
115
  # @rbs filter: String?
116
+ # @rbs priority: (Integer | Range[Integer?])?
117
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
118
+ # @rbs attempts: (Integer | Range[Integer?])?
113
119
  # @rbs from: String?
114
120
  # @rbs order: Zizq::sort_direction?
115
121
  # @rbs limit: Integer?
116
122
  # @rbs return: Resources::JobPage
117
- def list_jobs: (?id: (String | Array[String])?, ?status: (String | Array[String])?, ?queue: (String | Array[String])?, ?type: (String | Array[String])?, ?filter: String?, ?from: String?, ?order: Zizq::sort_direction?, ?limit: Integer?) -> Resources::JobPage
123
+ def list_jobs: (?id: (String | Array[String])?, ?status: (String | Array[String])?, ?queue: (String | Array[String])?, ?type: (String | Array[String])?, ?filter: String?, ?priority: (Integer | Range[Integer?])?, ?ready_at: (Zizq::to_f | Range[Zizq::to_f?])?, ?attempts: (Integer | Range[Integer?])?, ?from: String?, ?order: Zizq::sort_direction?, ?limit: Integer?) -> Resources::JobPage
118
124
 
119
125
  # Count jobs matching the given filters.
120
126
  #
@@ -126,8 +132,11 @@ module Zizq
126
132
  # @rbs queue: (String | Array[String])?
127
133
  # @rbs type: (String | Array[String])?
128
134
  # @rbs filter: String?
135
+ # @rbs priority: (Integer | Range[Integer?])?
136
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
137
+ # @rbs attempts: (Integer | Range[Integer?])?
129
138
  # @rbs return: Integer
130
- def count_jobs: (?id: (String | Array[String])?, ?status: (String | Array[String])?, ?queue: (String | Array[String])?, ?type: (String | Array[String])?, ?filter: String?) -> Integer
139
+ def count_jobs: (?id: (String | Array[String])?, ?status: (String | Array[String])?, ?queue: (String | Array[String])?, ?type: (String | Array[String])?, ?filter: String?, ?priority: (Integer | Range[Integer?])?, ?ready_at: (Zizq::to_f | Range[Zizq::to_f?])?, ?attempts: (Integer | Range[Integer?])?) -> Integer
131
140
 
132
141
  # Delete a single job by ID.
133
142
  #
@@ -146,6 +155,22 @@ module Zizq
146
155
  # @rbs return: Integer
147
156
  def delete_all_jobs: (?where: Zizq::where_params) -> Integer
148
157
 
158
+ # Wipe *every* cron group and *every* job on the server.
159
+ #
160
+ # Equivalent to calling `delete_all_crons` followed by
161
+ # `delete_all_jobs` (no filter), but in a single request. Useful
162
+ # primarily as a setup/teardown step in tests where you want a
163
+ # known-empty server between scenarios.
164
+ #
165
+ # **Destructive.** No filters, no escape hatch, no confirmation —
166
+ # the server-side operation simply returns once everything is gone.
167
+ #
168
+ # Named `erase_all_data` rather than `reset` because `Zizq.reset!`
169
+ # already exists at the module level for client-side SDK state.
170
+ #
171
+ # @rbs return: void
172
+ def erase_all_data: () -> void
173
+
149
174
  # Update a single job's mutable fields.
150
175
  #
151
176
  # Fields not provided are left unchanged. Use `Zizq::RESET` to clear
@@ -239,6 +264,19 @@ module Zizq
239
264
  # @rbs return: void
240
265
  def delete_cron_group: (String name) -> void
241
266
 
267
+ # Delete every cron group on the server in a single call.
268
+ #
269
+ # Returns the number of cron groups removed.
270
+ #
271
+ # **Destructive.** This deletes *every cron group on the server*.
272
+ # For granular deletes, use `delete_cron_group` with a specific
273
+ # name.
274
+ #
275
+ # Requires a Pro license on the server.
276
+ #
277
+ # @rbs return: Integer
278
+ def delete_all_crons: () -> Integer
279
+
242
280
  # Fetch a single cron entry.
243
281
  #
244
282
  # @rbs group: String
@@ -463,8 +501,30 @@ module Zizq
463
501
  # @rbs queue: (String | Array[String])?
464
502
  # @rbs type: (String | Array[String])?
465
503
  # @rbs filter: String?
504
+ # @rbs priority: (Integer | Range[Integer?])?
505
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
506
+ # @rbs attempts: (Integer | Range[Integer?])?
466
507
  # @rbs return: Hash[Symbol, untyped]
467
- def validate_where: (?id: (String | Array[String])?, ?status: (String | Array[String])?, ?queue: (String | Array[String])?, ?type: (String | Array[String])?, ?filter: String?) -> Hash[Symbol, untyped]
508
+ def validate_where: (?id: (String | Array[String])?, ?status: (String | Array[String])?, ?queue: (String | Array[String])?, ?type: (String | Array[String])?, ?filter: String?, ?priority: (Integer | Range[Integer?])?, ?ready_at: (Zizq::to_f | Range[Zizq::to_f?])?, ?attempts: (Integer | Range[Integer?])?) -> Hash[Symbol, untyped]
509
+
510
+ # Encode an Integer or Range filter into the server's query format.
511
+ #
512
+ # Accepted shapes:
513
+ #
514
+ # - `nil` -> `nil` (no filter sent)
515
+ # - `Integer` -> `"N"` (single value)
516
+ # - `(a..b)` -> `"A..B"` (inclusive both ends)
517
+ # - `(a..)` -> `"A.."` (lower bound only)
518
+ # - `(..b)` -> `"..B"` (upper bound only)
519
+ #
520
+ # Exclusive ranges (`a...b`, `a...`, `...b`) raise `ArgumentError` — the
521
+ # server only supports inclusive bounds. A bound transformation block can
522
+ # convert values before formatting (e.g. seconds -> ms for `ready_at`).
523
+ #
524
+ # @rbs value: untyped
525
+ # @rbs &block: ?(untyped) -> Integer
526
+ # @rbs return: String?
527
+ def encode_range: (untyped value) ?{ (untyped) -> Integer } -> String?
468
528
 
469
529
  # Validate set parameters via keyword args (rejects unknown keys) and
470
530
  # build the JSON body. Used by `update_all_jobs`.
@@ -46,11 +46,14 @@ module Zizq
46
46
  # @rbs type: (String | Array[String])?
47
47
  # @rbs status: (String | Array[String])?
48
48
  # @rbs jq_filter: String?
49
+ # @rbs priority: (Integer | Range[Integer?])?
50
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
51
+ # @rbs attempts: (Integer | Range[Integer?])?
49
52
  # @rbs order: Zizq::sort_direction?
50
53
  # @rbs limit: Integer?
51
54
  # @rbs page_size: Integer?
52
55
  # @rbs return: void
53
- def initialize: (?id: (String | Array[String])?, ?queue: (String | Array[String])?, ?type: (String | Array[String])?, ?status: (String | Array[String])?, ?jq_filter: String?, ?order: Zizq::sort_direction?, ?limit: Integer?, ?page_size: Integer?) -> void
56
+ def initialize: (?id: (String | Array[String])?, ?queue: (String | Array[String])?, ?type: (String | Array[String])?, ?status: (String | Array[String])?, ?jq_filter: String?, ?priority: (Integer | Range[Integer?])?, ?ready_at: (Zizq::to_f | Range[Zizq::to_f?])?, ?attempts: (Integer | Range[Integer?])?, ?order: Zizq::sort_direction?, ?limit: Integer?, ?page_size: Integer?) -> void
54
57
 
55
58
  # Set the page size for paginated iteration.
56
59
  #
@@ -110,6 +113,56 @@ module Zizq
110
113
  # @rbs return: Query
111
114
  def add_status: (String | Array[String] status) -> Query
112
115
 
116
+ # Filter by priority range (replaces any existing priority filter).
117
+ #
118
+ # Accepts an Integer (exact match) or an inclusive Range. Lower numbers
119
+ # are higher priority. Exclusive ranges (e.g. `0...100`) raise
120
+ # `ArgumentError` — the server only supports inclusive bounds.
121
+ #
122
+ # Examples:
123
+ #
124
+ # .by_priority(50) # exactly priority 50
125
+ # .by_priority(0..100) # between 0 and 100 inclusive
126
+ # .by_priority(100..) # 100 or greater
127
+ # .by_priority(..100) # 100 or less
128
+ #
129
+ # @rbs priority: (Integer | Range[Integer?])?
130
+ # @rbs return: Query
131
+ def by_priority: ((Integer | Range[Integer?])? priority) -> Query
132
+
133
+ # Filter by `ready_at` range (replaces any existing `ready_at` filter).
134
+ #
135
+ # Accepts a value (`Time`, `Numeric`, anything that responds to `to_f`)
136
+ # for an exact match, or an inclusive Range. Values are interpreted as
137
+ # fractional seconds on the Ruby side and converted to milliseconds for
138
+ # the server. Exclusive ranges raise `ArgumentError`.
139
+ #
140
+ # Examples:
141
+ #
142
+ # .by_ready_at(Time.now..) # ready to run now or later
143
+ # .by_ready_at(..Time.now) # was ready to run by now
144
+ # .by_ready_at(t1..t2) # ready between t1 and t2
145
+ #
146
+ # @rbs ready_at: (Zizq::to_f | Range[Zizq::to_f?])?
147
+ # @rbs return: Query
148
+ def by_ready_at: ((Zizq::to_f | Range[Zizq::to_f?])? ready_at) -> Query
149
+
150
+ # Filter by `attempts` range (replaces any existing `attempts` filter).
151
+ #
152
+ # Accepts an Integer (exact match) or an inclusive Range. `attempts` is
153
+ # the number of times the job has failed. Exclusive ranges raise
154
+ # `ArgumentError`.
155
+ #
156
+ # Examples:
157
+ #
158
+ # .by_attempts(0) # never failed
159
+ # .by_attempts(1..) # has failed at least once
160
+ # .by_attempts(1..3) # has failed 1, 2, or 3 times
161
+ #
162
+ # @rbs attempts: (Integer | Range[Integer?])?
163
+ # @rbs return: Query
164
+ def by_attempts: ((Integer | Range[Integer?])? attempts) -> Query
165
+
113
166
  # Filter by job class and exact arguments.
114
167
  #
115
168
  # The job class must include `Zizq::Job` or for Active Job classes must
@@ -332,7 +385,7 @@ module Zizq
332
385
  # Build a new Query with the given overrides, preserving all other fields.
333
386
  #
334
387
  # @rbs return: Query
335
- def rebuild: (?id: untyped, ?queue: untyped, ?type: untyped, ?status: untyped, ?jq_filter: untyped, ?order: untyped, ?limit: untyped, ?page_size: untyped) -> Query
388
+ def rebuild: (?id: untyped, ?queue: untyped, ?type: untyped, ?status: untyped, ?jq_filter: untyped, ?priority: untyped, ?ready_at: untyped, ?attempts: untyped, ?order: untyped, ?limit: untyped, ?page_size: untyped) -> Query
336
389
 
337
390
  # @rbs job_class: untyped
338
391
  # @rbs return: void
@@ -24,7 +24,7 @@ module Zizq
24
24
  #
25
25
  # @rbs &block: (T) -> void
26
26
  # @rbs return: Enumerator[T, void] | void
27
- def each: () { (T) -> void } -> (Enumerator[T, void] | void)
27
+ def each: () { (T) -> void } -> untyped
28
28
 
29
29
  # Returns true if there is a next page that can be fetched.
30
30
  def has_next?: () -> untyped
data/sig/zizq.rbs CHANGED
@@ -32,7 +32,10 @@ module Zizq
32
32
  ?status: (String | Array[String])?,
33
33
  ?queue: (String | Array[String])?,
34
34
  ?type: (String | Array[String])?,
35
- ?filter: String?
35
+ ?filter: String?,
36
+ ?priority: (Integer | Range[Integer?])?,
37
+ ?ready_at: (to_f | Range[to_f?])?,
38
+ ?attempts: (Integer | Range[Integer?])?
36
39
  }
37
40
 
38
41
  # Update parameters for single and bulk update operations.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zizq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Corbyn <chris@zizq.io>
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-28 00:00:00.000000000 Z
11
+ date: 2026-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http