zizq 0.1.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +94 -0
- data/bin/profile-worker +145 -0
- data/bin/zizq-worker +174 -0
- data/lib/active_job/queue_adapters/zizq_adapter.rb +109 -0
- data/lib/zizq/ack_processor.rb +132 -0
- data/lib/zizq/active_job_config.rb +122 -0
- data/lib/zizq/backoff.rb +50 -0
- data/lib/zizq/bulk_enqueue.rb +87 -0
- data/lib/zizq/client.rb +982 -0
- data/lib/zizq/configuration.rb +164 -0
- data/lib/zizq/enqueue_request.rb +178 -0
- data/lib/zizq/enqueue_with.rb +109 -0
- data/lib/zizq/error.rb +43 -0
- data/lib/zizq/job.rb +188 -0
- data/lib/zizq/job_config.rb +244 -0
- data/lib/zizq/lifecycle.rb +58 -0
- data/lib/zizq/middleware.rb +79 -0
- data/lib/zizq/query.rb +566 -0
- data/lib/zizq/resources/error_enumerator.rb +241 -0
- data/lib/zizq/resources/error_page.rb +19 -0
- data/lib/zizq/resources/error_record.rb +19 -0
- data/lib/zizq/resources/job.rb +124 -0
- data/lib/zizq/resources/job_page.rb +57 -0
- data/lib/zizq/resources/page.rb +77 -0
- data/lib/zizq/resources/resource.rb +45 -0
- data/lib/zizq/resources.rb +16 -0
- data/lib/zizq/version.rb +9 -0
- data/lib/zizq/worker.rb +467 -0
- data/lib/zizq.rb +269 -0
- data/sig/generated/zizq/ack_processor.rbs +73 -0
- data/sig/generated/zizq/active_job_config.rbs +74 -0
- data/sig/generated/zizq/backoff.rbs +34 -0
- data/sig/generated/zizq/bulk_enqueue.rbs +72 -0
- data/sig/generated/zizq/client.rbs +419 -0
- data/sig/generated/zizq/configuration.rbs +95 -0
- data/sig/generated/zizq/enqueue_request.rbs +94 -0
- data/sig/generated/zizq/enqueue_with.rbs +88 -0
- data/sig/generated/zizq/error.rbs +41 -0
- data/sig/generated/zizq/job.rbs +136 -0
- data/sig/generated/zizq/job_config.rbs +150 -0
- data/sig/generated/zizq/lifecycle.rbs +34 -0
- data/sig/generated/zizq/middleware.rbs +50 -0
- data/sig/generated/zizq/query.rbs +327 -0
- data/sig/generated/zizq/resources/error_enumerator.rbs +148 -0
- data/sig/generated/zizq/resources/error_page.rbs +13 -0
- data/sig/generated/zizq/resources/error_record.rbs +20 -0
- data/sig/generated/zizq/resources/job.rbs +89 -0
- data/sig/generated/zizq/resources/job_page.rbs +33 -0
- data/sig/generated/zizq/resources/page.rbs +47 -0
- data/sig/generated/zizq/resources/resource.rbs +26 -0
- data/sig/generated/zizq/version.rbs +5 -0
- data/sig/generated/zizq/worker.rbs +152 -0
- data/sig/generated/zizq.rbs +180 -0
- data/sig/zizq.rbs +111 -0
- metadata +134 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# Generated from lib/zizq/query.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
# Composable query builder for jobs in Zizq.
|
|
5
|
+
#
|
|
6
|
+
# Provides a chainable, immutable API for filtering, iterating, updating,
|
|
7
|
+
# and deleting jobs. Each filter method returns a new `Query` instance,
|
|
8
|
+
# leaving the original unchanged.
|
|
9
|
+
#
|
|
10
|
+
# `Query` is `Enumerable`— it lazily paginates through results, so
|
|
11
|
+
# standard Ruby methods like `count`, `map`, `select`, `first`, etc.
|
|
12
|
+
# work out of the box.
|
|
13
|
+
#
|
|
14
|
+
# Examples:
|
|
15
|
+
#
|
|
16
|
+
# # Count ready jobs on a queue
|
|
17
|
+
# Zizq::Query.new.by_queue("emails").by_status("ready").count
|
|
18
|
+
#
|
|
19
|
+
# # Move all jobs from one queue to another
|
|
20
|
+
# Zizq::Query.new.by_queue("old").update_all(queue: "new")
|
|
21
|
+
#
|
|
22
|
+
# # Delete dead jobs matching a payload filter
|
|
23
|
+
# Zizq::Query.new.by_status("dead").add_jq_filter(".user_id == 42").delete_all
|
|
24
|
+
#
|
|
25
|
+
# # Iterate in batches
|
|
26
|
+
# Zizq::Query.new.in_pages_of(100).each { |job| puts job.id }
|
|
27
|
+
#
|
|
28
|
+
# # Move all jobs from one queue to another in batches.
|
|
29
|
+
# Zizq::Query.new.by_queue("old").in_pages_of(100).update_all(queue: "new")
|
|
30
|
+
#
|
|
31
|
+
# # Find jobs by class and arguments
|
|
32
|
+
# Zizq::Query.new.by_job_class_and_args(SendEmailJob, 42, template: "welcome")
|
|
33
|
+
#
|
|
34
|
+
# # Find jobs by class and arguments (subset)
|
|
35
|
+
# Zizq::Query.new.by_job_class_and_args_subset(SendEmailJob, 42)
|
|
36
|
+
class Query
|
|
37
|
+
# Maximum page size the server can handle.
|
|
38
|
+
MAX_PAGE_SIZE: Integer
|
|
39
|
+
|
|
40
|
+
include ::Enumerable[Zizq::Resources::Job]
|
|
41
|
+
|
|
42
|
+
# Initialize the query with some initial parameters.
|
|
43
|
+
#
|
|
44
|
+
# @rbs id: (String | Array[String])?
|
|
45
|
+
# @rbs queue: (String | Array[String])?
|
|
46
|
+
# @rbs type: (String | Array[String])?
|
|
47
|
+
# @rbs status: (String | Array[String])?
|
|
48
|
+
# @rbs jq_filter: String?
|
|
49
|
+
# @rbs order: Zizq::sort_direction?
|
|
50
|
+
# @rbs limit: Integer?
|
|
51
|
+
# @rbs page_size: Integer?
|
|
52
|
+
# @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
|
|
54
|
+
|
|
55
|
+
# Set the page size for paginated iteration.
|
|
56
|
+
#
|
|
57
|
+
# When set, `each_page` fetches pages of this size, and `each` fetches jobs
|
|
58
|
+
# in pages of this size. Also used by `update_all` and `delete_all` to
|
|
59
|
+
# batch operations by page.
|
|
60
|
+
#
|
|
61
|
+
# @rbs page_size: Integer?
|
|
62
|
+
# @rbs return: Query
|
|
63
|
+
def in_pages_of: (Integer? page_size) -> Query
|
|
64
|
+
|
|
65
|
+
# Filter by job ID (replaces any existing ID filter).
|
|
66
|
+
#
|
|
67
|
+
# @rbs id: (String | Array[String])?
|
|
68
|
+
# @rbs return: Query
|
|
69
|
+
def by_id: ((String | Array[String])? id) -> Query
|
|
70
|
+
|
|
71
|
+
# Add a job ID to the existing ID filter.
|
|
72
|
+
#
|
|
73
|
+
# @rbs id: String | Array[String]
|
|
74
|
+
# @rbs return: Query
|
|
75
|
+
def add_id: (String | Array[String] id) -> Query
|
|
76
|
+
|
|
77
|
+
# Filter by queue name (replaces any existing queue filter).
|
|
78
|
+
#
|
|
79
|
+
# @rbs queue: (String | Array[String])?
|
|
80
|
+
# @rbs return: Query
|
|
81
|
+
def by_queue: ((String | Array[String])? queue) -> Query
|
|
82
|
+
|
|
83
|
+
# Add a queue to the existing queue filter.
|
|
84
|
+
#
|
|
85
|
+
# @rbs queue: String | Array[String]
|
|
86
|
+
# @rbs return: Query
|
|
87
|
+
def add_queue: (String | Array[String] queue) -> Query
|
|
88
|
+
|
|
89
|
+
# Filter by job type (replaces any existing type filter).
|
|
90
|
+
#
|
|
91
|
+
# @rbs type: (String | Array[String])?
|
|
92
|
+
# @rbs return: Query
|
|
93
|
+
def by_type: ((String | Array[String])? type) -> Query
|
|
94
|
+
|
|
95
|
+
# Add a type to the existing type filter.
|
|
96
|
+
#
|
|
97
|
+
# @rbs type: String | Array[String]
|
|
98
|
+
# @rbs return: Query
|
|
99
|
+
def add_type: (String | Array[String] type) -> Query
|
|
100
|
+
|
|
101
|
+
# Filter by status (replaces any existing status filter).
|
|
102
|
+
#
|
|
103
|
+
# @rbs status: (String | Array[String])
|
|
104
|
+
# @rbs return: Query
|
|
105
|
+
def by_status: (String | Array[String] status) -> Query
|
|
106
|
+
|
|
107
|
+
# Add a status to the existing status filter.
|
|
108
|
+
#
|
|
109
|
+
# @rbs status: String | Array[String]
|
|
110
|
+
# @rbs return: Query
|
|
111
|
+
def add_status: (String | Array[String] status) -> Query
|
|
112
|
+
|
|
113
|
+
# Filter by job class and exact arguments.
|
|
114
|
+
#
|
|
115
|
+
# The job class must include `Zizq::Job` or for Active Job classes must
|
|
116
|
+
# extend `Zizq::ActiveJobConfig`.
|
|
117
|
+
#
|
|
118
|
+
# Sets the type filter to the class name and adds a jq payload filter
|
|
119
|
+
# for an exact match of the serialized arguments.
|
|
120
|
+
#
|
|
121
|
+
# @rbs job_class: Zizq::job_class
|
|
122
|
+
# @rbs *args: untyped
|
|
123
|
+
# @rbs **kwargs: untyped
|
|
124
|
+
# @rbs return: Query
|
|
125
|
+
def by_job_class_and_args: (Zizq::job_class job_class, *untyped args, **untyped kwargs) -> Query
|
|
126
|
+
|
|
127
|
+
# Filter by job class and a subset of arguments.
|
|
128
|
+
#
|
|
129
|
+
# Matches jobs whose positional args start with the given values and
|
|
130
|
+
# whose kwargs contain (at minimum) the given key/value pairs.
|
|
131
|
+
#
|
|
132
|
+
# The job class must include `Zizq::Job` or for Active Job classes must
|
|
133
|
+
# extend `Zizq::ActiveJobConfig`.
|
|
134
|
+
#
|
|
135
|
+
# @rbs job_class: Zizq::job_class
|
|
136
|
+
# @rbs *args: untyped
|
|
137
|
+
# @rbs **kwargs: untyped
|
|
138
|
+
# @rbs return: Query
|
|
139
|
+
def by_job_class_and_args_subset: (Zizq::job_class job_class, *untyped args, **untyped kwargs) -> Query
|
|
140
|
+
|
|
141
|
+
# Replace the jq payload filter expression.
|
|
142
|
+
#
|
|
143
|
+
# @rbs jq_filter: String?
|
|
144
|
+
# @rbs return: Query
|
|
145
|
+
def by_jq_filter: (String? jq_filter) -> Query
|
|
146
|
+
|
|
147
|
+
# Add a jq payload filter, logically combines with any existing filter via
|
|
148
|
+
# "and".
|
|
149
|
+
#
|
|
150
|
+
# @rbs jq_filter: String
|
|
151
|
+
# @rbs return: Query
|
|
152
|
+
def add_jq_filter: (String jq_filter) -> Query
|
|
153
|
+
|
|
154
|
+
# Set the sort order for iteration.
|
|
155
|
+
#
|
|
156
|
+
# @rbs order: Zizq::sort_direction?
|
|
157
|
+
# @rbs return: Query
|
|
158
|
+
def order: (Zizq::sort_direction? order) -> Query
|
|
159
|
+
|
|
160
|
+
# Limit the total number of jobs returned.
|
|
161
|
+
#
|
|
162
|
+
# This is a total limit, imposed across potentially multiple page fetches.
|
|
163
|
+
# This limit also applies to `update_all` and `delete_all` operations.
|
|
164
|
+
#
|
|
165
|
+
# @rbs limit: Integer?
|
|
166
|
+
# @rbs return: Query
|
|
167
|
+
def limit: (Integer? limit) -> Query
|
|
168
|
+
|
|
169
|
+
# Reverse the sort order.
|
|
170
|
+
#
|
|
171
|
+
# Returns a new query with the opposite order. If no order was set,
|
|
172
|
+
# defaults to descending (the server default is ascending).
|
|
173
|
+
#
|
|
174
|
+
# @rbs return: Query
|
|
175
|
+
def reverse_order: () -> Query
|
|
176
|
+
|
|
177
|
+
# Returns true if there are no matching jobs.
|
|
178
|
+
#
|
|
179
|
+
# Optimised: fetches a single job to check.
|
|
180
|
+
#
|
|
181
|
+
# @rbs return: bool
|
|
182
|
+
def empty?: () -> bool
|
|
183
|
+
|
|
184
|
+
# Returns true if there are any matching jobs.
|
|
185
|
+
#
|
|
186
|
+
# Without a block, optimised to fetch a single job. With a block,
|
|
187
|
+
# falls back to Enumerable (tests each job against the block).
|
|
188
|
+
#
|
|
189
|
+
# @rbs &block: ?(Resources::Job) -> bool
|
|
190
|
+
# @rbs return: bool
|
|
191
|
+
def any?: () ?{ (Resources::Job) -> bool } -> bool
|
|
192
|
+
|
|
193
|
+
# Returns true if there are no matching jobs.
|
|
194
|
+
#
|
|
195
|
+
# Without a block, optimised to fetch a single job. With a block,
|
|
196
|
+
# falls back to Enumerable (tests each job against the block).
|
|
197
|
+
#
|
|
198
|
+
# @rbs &block: ?(Resources::Job) -> bool
|
|
199
|
+
# @rbs return: bool
|
|
200
|
+
def none?: () ?{ (Resources::Job) -> bool } -> bool
|
|
201
|
+
|
|
202
|
+
# Returns true if there is exactly one matching job.
|
|
203
|
+
#
|
|
204
|
+
# Without a block, optimised to fetch at most two jobs. With a block,
|
|
205
|
+
# falls back to Enumerable.
|
|
206
|
+
#
|
|
207
|
+
# @rbs &block: ?(Resources::Job) -> bool
|
|
208
|
+
# @rbs return: bool
|
|
209
|
+
def one?: () ?{ (Resources::Job) -> bool } -> bool
|
|
210
|
+
|
|
211
|
+
# Iterate over matching jobs in reverse order.
|
|
212
|
+
#
|
|
213
|
+
# Optimised: pushes the reverse ordering to the server instead of
|
|
214
|
+
# fetching all jobs into memory and reversing.
|
|
215
|
+
#
|
|
216
|
+
# @rbs &block: ?(Resources::Job) -> void
|
|
217
|
+
# @rbs return: ::Enumerator[Zizq::Resources::Job, void]
|
|
218
|
+
def reverse_each: () ?{ (Resources::Job) -> void } -> ::Enumerator[Zizq::Resources::Job, void]
|
|
219
|
+
|
|
220
|
+
# Return the first matching job, or nil if none match.
|
|
221
|
+
#
|
|
222
|
+
# Optimised: fetches a single job from the server (`?limit=1`).
|
|
223
|
+
#
|
|
224
|
+
# @rbs return: Resources::Job?
|
|
225
|
+
def first: () -> Resources::Job?
|
|
226
|
+
|
|
227
|
+
# Return the last matching job, or nil if none match.
|
|
228
|
+
#
|
|
229
|
+
# Optimised: reverses the order and fetches a single job.
|
|
230
|
+
#
|
|
231
|
+
# @rbs return: Resources::Job?
|
|
232
|
+
def last: () -> Resources::Job?
|
|
233
|
+
|
|
234
|
+
# Return the first `n` matching jobs.
|
|
235
|
+
#
|
|
236
|
+
# Optimised: sets the limit to `n` so the server only returns what's
|
|
237
|
+
# needed.
|
|
238
|
+
#
|
|
239
|
+
# @rbs n: Integer
|
|
240
|
+
# @rbs return: Array[Resources::Job]
|
|
241
|
+
def take: (Integer n) -> Array[Resources::Job]
|
|
242
|
+
|
|
243
|
+
# Update the first matching job.
|
|
244
|
+
#
|
|
245
|
+
# Returns 1 if a job was updated, 0 if no jobs matched.
|
|
246
|
+
#
|
|
247
|
+
# @rbs queue: (String | singleton(Zizq::UNCHANGED))?
|
|
248
|
+
# @rbs priority: (Integer | singleton(Zizq::UNCHANGED))?
|
|
249
|
+
# @rbs ready_at: (Zizq::to_f | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
250
|
+
# @rbs retry_limit: (Integer | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
251
|
+
# @rbs backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
252
|
+
# @rbs retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
253
|
+
# @rbs return: Integer
|
|
254
|
+
def update_one: () -> Integer
|
|
255
|
+
|
|
256
|
+
# Delete the first matching job.
|
|
257
|
+
#
|
|
258
|
+
# Returns 1 if a job was deleted, 0 if no jobs matched.
|
|
259
|
+
#
|
|
260
|
+
# @rbs return: Integer
|
|
261
|
+
def delete_one: () -> Integer
|
|
262
|
+
|
|
263
|
+
# Iterate over matching jobs, lazily paginating through results.
|
|
264
|
+
#
|
|
265
|
+
# Respects `limit` if set. Without a block, returns an `Enumerator`.
|
|
266
|
+
#
|
|
267
|
+
# @rbs &block: ?(Resources::Job) -> void
|
|
268
|
+
# @rbs return: ::Enumerator[Zizq::Resources::Job, void]
|
|
269
|
+
def each: () ?{ (Resources::Job) -> void } -> ::Enumerator[Zizq::Resources::Job, void]
|
|
270
|
+
|
|
271
|
+
# Iterate over pages of matching jobs.
|
|
272
|
+
#
|
|
273
|
+
# Each page is a `Resources::JobPage`. Without a block, returns an
|
|
274
|
+
# `Enumerator`.
|
|
275
|
+
#
|
|
276
|
+
# If `limit` is set, terminates after the last page is reached that exceeds
|
|
277
|
+
# the limit, but does not truncate the page.
|
|
278
|
+
#
|
|
279
|
+
# @rbs &block: ?(Resources::JobPage) -> void
|
|
280
|
+
# @rbs return: ::Enumerator[Zizq::Resources::JobPage, void]
|
|
281
|
+
def each_page: () ?{ (Resources::JobPage) -> void } -> ::Enumerator[Zizq::Resources::JobPage, void]
|
|
282
|
+
|
|
283
|
+
# Update all matching jobs with the given field values.
|
|
284
|
+
#
|
|
285
|
+
# When `page_size` or `limit` is set, iterates page by page and
|
|
286
|
+
# issues a bulk update per page using the job IDs on that page. For safety
|
|
287
|
+
# query parameters are included in the scope along with all IDs. Otherwise,
|
|
288
|
+
# issues a single bulk update with the query parameters.
|
|
289
|
+
#
|
|
290
|
+
# Returns the total number of updated jobs.
|
|
291
|
+
#
|
|
292
|
+
# @rbs queue: (String | singleton(Zizq::UNCHANGED))?
|
|
293
|
+
# @rbs priority: (Integer | singleton(Zizq::UNCHANGED))?
|
|
294
|
+
# @rbs ready_at: (Zizq::to_f | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
295
|
+
# @rbs retry_limit: (Integer | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
296
|
+
# @rbs backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
297
|
+
# @rbs retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
298
|
+
# @rbs return: Integer
|
|
299
|
+
def update_all: (?queue: (String | singleton(Zizq::UNCHANGED))?, ?priority: (Integer | singleton(Zizq::UNCHANGED))?, ?ready_at: (Zizq::to_f | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?, ?retry_limit: (Integer | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?, ?backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?, ?retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?) -> Integer
|
|
300
|
+
|
|
301
|
+
# Delete all matching jobs.
|
|
302
|
+
#
|
|
303
|
+
# When `page_size` or `limit` is set, iterates page by page and
|
|
304
|
+
# issues a bulk delete per page using the job IDs on that page. For safety
|
|
305
|
+
# query parameters are included in the scope along with all IDs. Otherwise,
|
|
306
|
+
# issues a single bulk delete with the query filters.
|
|
307
|
+
#
|
|
308
|
+
# When called in a bare query, this deletes *all* jobs from the server,
|
|
309
|
+
# which is useful in tests.
|
|
310
|
+
#
|
|
311
|
+
# Returns the total number of deleted jobs.
|
|
312
|
+
#
|
|
313
|
+
# @rbs return: Integer
|
|
314
|
+
def delete_all: () -> Integer
|
|
315
|
+
|
|
316
|
+
private
|
|
317
|
+
|
|
318
|
+
# Build a new Query with the given overrides, preserving all other fields.
|
|
319
|
+
#
|
|
320
|
+
# @rbs return: Query
|
|
321
|
+
def rebuild: (?id: untyped, ?queue: untyped, ?type: untyped, ?status: untyped, ?jq_filter: untyped, ?order: untyped, ?limit: untyped, ?page_size: untyped) -> Query
|
|
322
|
+
|
|
323
|
+
# @rbs job_class: untyped
|
|
324
|
+
# @rbs return: void
|
|
325
|
+
def validate_job_class!: (untyped job_class) -> void
|
|
326
|
+
end
|
|
327
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Generated from lib/zizq/resources/error_enumerator.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
module Resources
|
|
5
|
+
# Provides a lazy Enumerator across all errors on a job following the
|
|
6
|
+
# cursor-based pagination.
|
|
7
|
+
class ErrorEnumerator
|
|
8
|
+
# Maximum page size the server can handle.
|
|
9
|
+
MAX_PAGE_SIZE: Integer
|
|
10
|
+
|
|
11
|
+
include ::Enumerable[Zizq::Resources::ErrorRecord]
|
|
12
|
+
|
|
13
|
+
# Initialize the enumerator.
|
|
14
|
+
#
|
|
15
|
+
# @rbs id: String
|
|
16
|
+
# @rbs order: Zizq::sort_direction?
|
|
17
|
+
# @rbs limit: Integer?
|
|
18
|
+
# @rbs page_size: Integer?
|
|
19
|
+
# @rbs return: void
|
|
20
|
+
def initialize: (String id, ?order: Zizq::sort_direction?, ?limit: Integer?, ?page_size: Integer?) -> void
|
|
21
|
+
|
|
22
|
+
# Set the page size for paginated iteration.
|
|
23
|
+
#
|
|
24
|
+
# When set, `each_page` fetches pages of this size, and `each` fetches
|
|
25
|
+
# errors in pages of this size.
|
|
26
|
+
#
|
|
27
|
+
# @rbs page_size: Integer?
|
|
28
|
+
# @rbs return: ErrorEnumerator
|
|
29
|
+
def in_pages_of: (Integer? page_size) -> ErrorEnumerator
|
|
30
|
+
|
|
31
|
+
# Set the sort order for iteration.
|
|
32
|
+
#
|
|
33
|
+
# @rbs order: Zizq::sort_direction?
|
|
34
|
+
# @rbs return: ErrorEnumerator
|
|
35
|
+
def order: (Zizq::sort_direction? order) -> ErrorEnumerator
|
|
36
|
+
|
|
37
|
+
# Limit the total number of errors returned.
|
|
38
|
+
#
|
|
39
|
+
# This is a total limit, imposed across potentially multiple page fetches.
|
|
40
|
+
#
|
|
41
|
+
# @rbs limit: Integer?
|
|
42
|
+
# @rbs return: ErrorEnumerator
|
|
43
|
+
def limit: (Integer? limit) -> ErrorEnumerator
|
|
44
|
+
|
|
45
|
+
# Reverse the sort order.
|
|
46
|
+
#
|
|
47
|
+
# Returns a new query with the opposite order. If no order was set,
|
|
48
|
+
# defaults to descending (the server default is ascending).
|
|
49
|
+
#
|
|
50
|
+
# @rbs return: ErrorEnumerator
|
|
51
|
+
def reverse_order: () -> ErrorEnumerator
|
|
52
|
+
|
|
53
|
+
# Returns true if there are no errors.
|
|
54
|
+
#
|
|
55
|
+
# Optimised: fetches a single error to check.
|
|
56
|
+
#
|
|
57
|
+
# @rbs return: bool
|
|
58
|
+
def empty?: () -> bool
|
|
59
|
+
|
|
60
|
+
# Returns true if there are any errors.
|
|
61
|
+
#
|
|
62
|
+
# Without a block, optimised to fetch a single error. With a block,
|
|
63
|
+
# falls back to Enumerable (tests each error against the block).
|
|
64
|
+
#
|
|
65
|
+
# @rbs &block: ?(Resources::ErrorRecord) -> bool
|
|
66
|
+
# @rbs return: bool
|
|
67
|
+
def any?: () ?{ (Resources::ErrorRecord) -> bool } -> bool
|
|
68
|
+
|
|
69
|
+
# Returns true if there are no errors.
|
|
70
|
+
#
|
|
71
|
+
# Without a block, optimised to fetch a single error. With a block,
|
|
72
|
+
# falls back to Enumerable (tests each error against the block).
|
|
73
|
+
#
|
|
74
|
+
# @rbs &block: ?(Resources::ErrorRecord) -> bool
|
|
75
|
+
# @rbs return: bool
|
|
76
|
+
def none?: () ?{ (Resources::ErrorRecord) -> bool } -> bool
|
|
77
|
+
|
|
78
|
+
# Returns true if there is exactly one error.
|
|
79
|
+
#
|
|
80
|
+
# Without a block, optimised to fetch at most two errors. With a block,
|
|
81
|
+
# falls back to Enumerable.
|
|
82
|
+
#
|
|
83
|
+
# @rbs &block: ?(Resources::ErrorRecord) -> bool
|
|
84
|
+
# @rbs return: bool
|
|
85
|
+
def one?: () ?{ (Resources::ErrorRecord) -> bool } -> bool
|
|
86
|
+
|
|
87
|
+
# Iterate over errors in reverse order.
|
|
88
|
+
#
|
|
89
|
+
# Optimised: pushes the reverse ordering to the server instead of
|
|
90
|
+
# fetching all errors into memory and reversing.
|
|
91
|
+
#
|
|
92
|
+
# @rbs &block: ?(Resources::ErrorRecord) -> void
|
|
93
|
+
# @rbs return: ::Enumerator[Zizq::Resources::ErrorRecord, void]
|
|
94
|
+
def reverse_each: () ?{ (Resources::ErrorRecord) -> void } -> ::Enumerator[Zizq::Resources::ErrorRecord, void]
|
|
95
|
+
|
|
96
|
+
# Return the first error, or nil if no errors.
|
|
97
|
+
#
|
|
98
|
+
# Optimised: fetches a single error from the server (`?limit=1`).
|
|
99
|
+
#
|
|
100
|
+
# @rbs return: Resources::ErrorRecord?
|
|
101
|
+
def first: () -> Resources::ErrorRecord?
|
|
102
|
+
|
|
103
|
+
# Return the last error, or nil if no errors.
|
|
104
|
+
#
|
|
105
|
+
# Optimised: reverses the order and fetches a single error.
|
|
106
|
+
#
|
|
107
|
+
# @rbs return: Resources::ErrorRecord?
|
|
108
|
+
def last: () -> Resources::ErrorRecord?
|
|
109
|
+
|
|
110
|
+
# Return the first `n` errors.
|
|
111
|
+
#
|
|
112
|
+
# Optimised: sets the limit to `n` so the server only returns what's
|
|
113
|
+
# needed.
|
|
114
|
+
#
|
|
115
|
+
# @rbs n: Integer
|
|
116
|
+
# @rbs return: Array[Resources::ErrorRecord]
|
|
117
|
+
def take: (Integer n) -> Array[Resources::ErrorRecord]
|
|
118
|
+
|
|
119
|
+
# Iterate over errors, lazily paginating through results.
|
|
120
|
+
#
|
|
121
|
+
# Respects `limit` if set. Without a block, returns an `Enumerator`.
|
|
122
|
+
#
|
|
123
|
+
# @rbs &block: ?(Resources::ErrorRecord) -> void
|
|
124
|
+
# @rbs return: ::Enumerator[Zizq::Resources::ErrorRecord, void]
|
|
125
|
+
def each: () ?{ (Resources::ErrorRecord) -> void } -> ::Enumerator[Zizq::Resources::ErrorRecord, void]
|
|
126
|
+
|
|
127
|
+
# Iterate over pages of errors.
|
|
128
|
+
#
|
|
129
|
+
# Each page is a `Resources::ErrorPage`. Without a block, returns an
|
|
130
|
+
# `Enumerator`.
|
|
131
|
+
#
|
|
132
|
+
# If `limit` is set, terminates after the last page is reached that
|
|
133
|
+
# exceeds the limit, but does not truncate the page.
|
|
134
|
+
#
|
|
135
|
+
# @rbs &block: ?(Resources::ErrorPage) -> void
|
|
136
|
+
# @rbs return: ::Enumerator[Zizq::Resources::ErrorPage, void]
|
|
137
|
+
def each_page: () ?{ (Resources::ErrorPage) -> void } -> ::Enumerator[Zizq::Resources::ErrorPage, void]
|
|
138
|
+
|
|
139
|
+
private
|
|
140
|
+
|
|
141
|
+
# Build a new ErrorEnumerator with the given overrides, preserving all
|
|
142
|
+
# other fields.
|
|
143
|
+
#
|
|
144
|
+
# @rbs return: ErrorEnumerator
|
|
145
|
+
def rebuild: (?untyped id, ?order: untyped, ?limit: untyped, ?page_size: untyped) -> ErrorEnumerator
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Generated from lib/zizq/resources/error_page.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
module Resources
|
|
5
|
+
# Paginated list of error records.
|
|
6
|
+
# @rbs inherits Page[ErrorRecord]
|
|
7
|
+
class ErrorPage < Page[ErrorRecord]
|
|
8
|
+
def items: () -> untyped
|
|
9
|
+
|
|
10
|
+
alias errors items
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Generated from lib/zizq/resources/error_record.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
module Resources
|
|
5
|
+
# Typed wrapper around a single error record from the job error history.
|
|
6
|
+
class ErrorRecord < Resource
|
|
7
|
+
def attempt: () -> untyped
|
|
8
|
+
|
|
9
|
+
def message: () -> untyped
|
|
10
|
+
|
|
11
|
+
def error_type: () -> untyped
|
|
12
|
+
|
|
13
|
+
def backtrace: () -> untyped
|
|
14
|
+
|
|
15
|
+
def dequeued_at: () -> untyped
|
|
16
|
+
|
|
17
|
+
def failed_at: () -> untyped
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Generated from lib/zizq/resources/job.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
module Resources
|
|
5
|
+
# Typed wrapper around a job response hash.
|
|
6
|
+
#
|
|
7
|
+
# Exposes named accessor methods with Ruby-idiomatic types (fractional
|
|
8
|
+
# seconds instead of milliseconds) and link methods that follow related
|
|
9
|
+
# resources through the Client.
|
|
10
|
+
class Job < Resource
|
|
11
|
+
def id: () -> untyped
|
|
12
|
+
|
|
13
|
+
def type: () -> untyped
|
|
14
|
+
|
|
15
|
+
def queue: () -> untyped
|
|
16
|
+
|
|
17
|
+
def priority: () -> untyped
|
|
18
|
+
|
|
19
|
+
def status: () -> untyped
|
|
20
|
+
|
|
21
|
+
def ready_at: () -> untyped
|
|
22
|
+
|
|
23
|
+
def attempts: () -> untyped
|
|
24
|
+
|
|
25
|
+
def payload: () -> untyped
|
|
26
|
+
|
|
27
|
+
def dequeued_at: () -> untyped
|
|
28
|
+
|
|
29
|
+
def failed_at: () -> untyped
|
|
30
|
+
|
|
31
|
+
def completed_at: () -> untyped
|
|
32
|
+
|
|
33
|
+
def retry_limit: () -> untyped
|
|
34
|
+
|
|
35
|
+
def unique_key: () -> untyped
|
|
36
|
+
|
|
37
|
+
def unique_while: () -> untyped
|
|
38
|
+
|
|
39
|
+
def duplicate?: () -> untyped
|
|
40
|
+
|
|
41
|
+
# Backoff configuration converted from the wire format (ms) to the
|
|
42
|
+
# Ruby-idiomatic format (seconds), matching the Zizq::backoff type.
|
|
43
|
+
def backoff: () -> untyped
|
|
44
|
+
|
|
45
|
+
# Retention configuration converted from the wire format (ms) to the
|
|
46
|
+
# Ruby-idiomatic format (seconds), matching the Zizq::retention type.
|
|
47
|
+
def retention: () -> untyped
|
|
48
|
+
|
|
49
|
+
# Fetch the error history for this job.
|
|
50
|
+
#
|
|
51
|
+
# @rbs order: Zizq::sort_direction?
|
|
52
|
+
# @rbs limit: Integer?
|
|
53
|
+
# @rbs page_size: Integer?
|
|
54
|
+
# @rbs return: ErrorEnumerator
|
|
55
|
+
def errors: (?order: Zizq::sort_direction?, ?limit: Integer?, ?page_size: Integer?) -> ErrorEnumerator
|
|
56
|
+
|
|
57
|
+
# Mark this job as successfully completed.
|
|
58
|
+
def complete!: () -> untyped
|
|
59
|
+
|
|
60
|
+
# Report this job as failed.
|
|
61
|
+
#
|
|
62
|
+
# @rbs message: String
|
|
63
|
+
# @rbs error_type: String?
|
|
64
|
+
# @rbs backtrace: String?
|
|
65
|
+
# @rbs retry_at: Float?
|
|
66
|
+
# @rbs kill: bool
|
|
67
|
+
# @rbs return: Job
|
|
68
|
+
def fail!: (message: String, ?error_type: String?, ?backtrace: String?, ?retry_at: Float?, ?kill: bool) -> Job
|
|
69
|
+
|
|
70
|
+
# Delete this job.
|
|
71
|
+
#
|
|
72
|
+
# @rbs return: void
|
|
73
|
+
def delete: () -> void
|
|
74
|
+
|
|
75
|
+
# Update this job's mutable fields.
|
|
76
|
+
#
|
|
77
|
+
# Returns the updated job.
|
|
78
|
+
#
|
|
79
|
+
# @rbs queue: (String | singleton(Zizq::UNCHANGED))?
|
|
80
|
+
# @rbs priority: (Integer | singleton(Zizq::UNCHANGED))?
|
|
81
|
+
# @rbs ready_at: (Zizq::to_f | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
82
|
+
# @rbs retry_limit: (Integer | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
83
|
+
# @rbs backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
84
|
+
# @rbs retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
85
|
+
# @rbs return: Job
|
|
86
|
+
def update: (?queue: (String | singleton(Zizq::UNCHANGED))?, ?priority: (Integer | singleton(Zizq::UNCHANGED))?, ?ready_at: (Zizq::to_f | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?, ?retry_limit: (Integer | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?, ?backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?, ?retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?) -> Job
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Generated from lib/zizq/resources/job_page.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
module Resources
|
|
5
|
+
# Paginated list of jobs.
|
|
6
|
+
# @rbs inherits Page[Job]
|
|
7
|
+
class JobPage < Page[Job]
|
|
8
|
+
def items: () -> untyped
|
|
9
|
+
|
|
10
|
+
alias jobs items
|
|
11
|
+
|
|
12
|
+
# Delete all jobs on this page.
|
|
13
|
+
#
|
|
14
|
+
# Returns the number of deleted jobs.
|
|
15
|
+
#
|
|
16
|
+
# @rbs return: Integer
|
|
17
|
+
def delete_all: () -> Integer
|
|
18
|
+
|
|
19
|
+
# Update all jobs on this page with the given field values.
|
|
20
|
+
#
|
|
21
|
+
# Returns the number of updated jobs.
|
|
22
|
+
#
|
|
23
|
+
# @rbs queue: (String | singleton(Zizq::UNCHANGED))?
|
|
24
|
+
# @rbs priority: (Integer | singleton(Zizq::UNCHANGED))?
|
|
25
|
+
# @rbs ready_at: (Zizq::to_f | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
26
|
+
# @rbs retry_limit: (Integer | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
27
|
+
# @rbs backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
28
|
+
# @rbs retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
29
|
+
# @rbs return: Integer
|
|
30
|
+
def update_all: (?queue: (String | singleton(Zizq::UNCHANGED))?, ?priority: (Integer | singleton(Zizq::UNCHANGED))?, ?ready_at: (Zizq::to_f | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?, ?retry_limit: (Integer | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?, ?backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?, ?retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?) -> Integer
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Generated from lib/zizq/resources/page.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
module Resources
|
|
5
|
+
# Base class for paginated list responses.
|
|
6
|
+
#
|
|
7
|
+
# Stores the raw response data and provides navigation helpers that
|
|
8
|
+
# follow pagination links through the Client.
|
|
9
|
+
#
|
|
10
|
+
# @rbs generic T < Resource
|
|
11
|
+
class Page[T < Resource] < Resource
|
|
12
|
+
include ::Enumerable[T]
|
|
13
|
+
|
|
14
|
+
# Wrapped resource objects for this page.
|
|
15
|
+
def items: () -> untyped
|
|
16
|
+
|
|
17
|
+
# Returns the underlying raw response hash.
|
|
18
|
+
#
|
|
19
|
+
# Re-declared here because Enumerable#to_h would otherwise shadow
|
|
20
|
+
# the Resource#to_h definition.
|
|
21
|
+
def to_h: () -> untyped
|
|
22
|
+
|
|
23
|
+
# Yields each item on this page. Required by Enumerable.
|
|
24
|
+
#
|
|
25
|
+
# @rbs &block: (T) -> void
|
|
26
|
+
# @rbs return: Enumerator[T, void] | void
|
|
27
|
+
def each: () { (T) -> void } -> (Enumerator[T, void] | void)
|
|
28
|
+
|
|
29
|
+
# Returns true if there is a next page that can be fetched.
|
|
30
|
+
def has_next?: () -> untyped
|
|
31
|
+
|
|
32
|
+
# Returns true if there is a previous page that can be fetched.
|
|
33
|
+
def has_prev?: () -> untyped
|
|
34
|
+
|
|
35
|
+
# Fetch the next page, or nil if there isn't one.
|
|
36
|
+
def next_page: () -> untyped
|
|
37
|
+
|
|
38
|
+
# Fetch the previous page, or nil if there isn't one.
|
|
39
|
+
def prev_page: () -> untyped
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
# Subclasses override to wrap the raw page data in the correct Page type.
|
|
44
|
+
def wrap_page: (untyped data) -> untyped
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|