zizq 0.5.0 → 0.6.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 +4 -4
- data/README.md +4 -3
- data/lib/active_job/queue_adapters/zizq_adapter.rb +42 -20
- data/lib/zizq/ack_processor.rb +17 -11
- data/lib/zizq/active_job_config.rb +30 -10
- data/lib/zizq/backoff.rb +5 -1
- data/lib/zizq/bulk_enqueue.rb +7 -1
- data/lib/zizq/client.rb +288 -185
- data/lib/zizq/configuration.rb +15 -14
- data/lib/zizq/crontab.rb +35 -33
- data/lib/zizq/crontab_builder.rb +1 -7
- data/lib/zizq/crontab_entry.rb +36 -35
- data/lib/zizq/crontab_entry_builder.rb +15 -18
- data/lib/zizq/enqueue_request.rb +51 -38
- data/lib/zizq/enqueue_with.rb +1 -3
- data/lib/zizq/error.rb +12 -6
- data/lib/zizq/job.rb +31 -13
- data/lib/zizq/job_config.rb +217 -13
- data/lib/zizq/lifecycle.rb +10 -2
- data/lib/zizq/middleware.rb +7 -6
- data/lib/zizq/query.rb +85 -67
- data/lib/zizq/resources/cron_entry.rb +7 -7
- data/lib/zizq/resources/cron_group.rb +5 -5
- data/lib/zizq/resources/error_enumerator.rb +11 -9
- data/lib/zizq/resources/error_page.rb +2 -1
- data/lib/zizq/resources/error_record.rb +5 -5
- data/lib/zizq/resources/job.rb +41 -24
- data/lib/zizq/resources/job_page.rb +19 -8
- data/lib/zizq/resources/job_template.rb +16 -8
- data/lib/zizq/resources/page.rb +2 -1
- data/lib/zizq/resources/resource.rb +5 -4
- data/lib/zizq/resources.rb +9 -9
- data/lib/zizq/router.rb +3 -2
- data/lib/zizq/test/client.rb +79 -58
- data/lib/zizq/test.rb +8 -8
- data/lib/zizq/tls_configuration.rb +7 -6
- data/lib/zizq/version.rb +1 -1
- data/lib/zizq/worker.rb +68 -50
- data/lib/zizq/worker_configuration.rb +11 -10
- data/lib/zizq.rb +48 -41
- data/sig/generated/zizq/active_job_config.rbs +16 -5
- data/sig/generated/zizq/bulk_enqueue.rbs +1 -0
- data/sig/generated/zizq/client.rbs +2 -1
- data/sig/generated/zizq/crontab_entry_builder.rbs +1 -0
- data/sig/generated/zizq/enqueue_request.rbs +7 -2
- data/sig/generated/zizq/job.rbs +6 -0
- data/sig/generated/zizq/job_config.rbs +98 -0
- data/sig/generated/zizq/resources/job.rbs +2 -0
- data/sig/generated/zizq/resources/job_template.rbs +5 -2
- data/sig/generated/zizq.rbs +1 -0
- data/sig/zizq.rbs +12 -1
- metadata +2 -2
data/lib/zizq/resources/job.rb
CHANGED
|
@@ -12,14 +12,15 @@ module Zizq
|
|
|
12
12
|
# retention, unique_key, unique_while) from JobTemplate and adds
|
|
13
13
|
# lifecycle fields and action methods.
|
|
14
14
|
class Job < JobTemplate
|
|
15
|
-
def id
|
|
16
|
-
def status
|
|
17
|
-
def ready_at
|
|
18
|
-
def attempts
|
|
15
|
+
def id = @data["id"] #: () -> String
|
|
16
|
+
def status = @data["status"] #: () -> String
|
|
17
|
+
def ready_at = ms_to_seconds(@data["ready_at"]) #: () -> Float?
|
|
18
|
+
def attempts = @data["attempts"] #: () -> Integer
|
|
19
19
|
def dequeued_at = ms_to_seconds(@data["dequeued_at"]) #: () -> Float?
|
|
20
|
-
def failed_at
|
|
21
|
-
def completed_at
|
|
22
|
-
def duplicate?
|
|
20
|
+
def failed_at = ms_to_seconds(@data["failed_at"]) #: () -> Float?
|
|
21
|
+
def completed_at = ms_to_seconds(@data["completed_at"]) #: () -> Float?
|
|
22
|
+
def duplicate? = @data["duplicate"] == true #: () -> bool
|
|
23
|
+
def folded? = @data["folded"] == true #: () -> bool
|
|
23
24
|
|
|
24
25
|
# Fetch the error history for this job.
|
|
25
26
|
#
|
|
@@ -44,8 +45,21 @@ module Zizq
|
|
|
44
45
|
# @rbs retry_at: Float?
|
|
45
46
|
# @rbs kill: bool
|
|
46
47
|
# @rbs return: Job
|
|
47
|
-
def fail!(
|
|
48
|
-
|
|
48
|
+
def fail!(
|
|
49
|
+
message:,
|
|
50
|
+
error_type: nil,
|
|
51
|
+
backtrace: nil,
|
|
52
|
+
retry_at: nil,
|
|
53
|
+
kill: false
|
|
54
|
+
)
|
|
55
|
+
@client.report_failure(
|
|
56
|
+
id,
|
|
57
|
+
message:,
|
|
58
|
+
error_type:,
|
|
59
|
+
backtrace:,
|
|
60
|
+
retry_at:,
|
|
61
|
+
kill:
|
|
62
|
+
)
|
|
49
63
|
end
|
|
50
64
|
|
|
51
65
|
# Delete this job.
|
|
@@ -66,21 +80,24 @@ module Zizq
|
|
|
66
80
|
# @rbs backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
67
81
|
# @rbs retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
68
82
|
# @rbs return: Job
|
|
69
|
-
def update(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
def update(
|
|
84
|
+
queue: Zizq::UNCHANGED,
|
|
85
|
+
priority: Zizq::UNCHANGED,
|
|
86
|
+
ready_at: Zizq::UNCHANGED,
|
|
87
|
+
retry_limit: Zizq::UNCHANGED,
|
|
88
|
+
backoff: Zizq::UNCHANGED,
|
|
89
|
+
retention: Zizq::UNCHANGED
|
|
90
|
+
)
|
|
91
|
+
job =
|
|
92
|
+
@client.update_job(
|
|
93
|
+
id,
|
|
94
|
+
queue:,
|
|
95
|
+
priority:,
|
|
96
|
+
ready_at:,
|
|
97
|
+
retry_limit:,
|
|
98
|
+
backoff:,
|
|
99
|
+
retention:
|
|
100
|
+
)
|
|
84
101
|
|
|
85
102
|
# Make sure this job's fields are updated.
|
|
86
103
|
@data.merge!(job.to_h)
|
|
@@ -38,18 +38,29 @@ module Zizq
|
|
|
38
38
|
# @rbs backoff: (Zizq::backoff | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
39
39
|
# @rbs retention: (Zizq::retention | singleton(Zizq::RESET) | singleton(Zizq::UNCHANGED))?
|
|
40
40
|
# @rbs return: Integer
|
|
41
|
-
def update_all(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
def update_all(
|
|
42
|
+
queue: Zizq::UNCHANGED,
|
|
43
|
+
priority: Zizq::UNCHANGED,
|
|
44
|
+
ready_at: Zizq::UNCHANGED,
|
|
45
|
+
retry_limit: Zizq::UNCHANGED,
|
|
46
|
+
backoff: Zizq::UNCHANGED,
|
|
47
|
+
retention: Zizq::UNCHANGED
|
|
48
|
+
)
|
|
47
49
|
ids = jobs.map(&:id)
|
|
48
50
|
return 0 if ids.empty?
|
|
49
51
|
|
|
50
52
|
client.update_all_jobs(
|
|
51
|
-
where: {
|
|
52
|
-
|
|
53
|
+
where: {
|
|
54
|
+
id: ids
|
|
55
|
+
},
|
|
56
|
+
apply: {
|
|
57
|
+
queue:,
|
|
58
|
+
priority:,
|
|
59
|
+
ready_at:,
|
|
60
|
+
retry_limit:,
|
|
61
|
+
backoff:,
|
|
62
|
+
retention:
|
|
63
|
+
}
|
|
53
64
|
)
|
|
54
65
|
end
|
|
55
66
|
end
|
|
@@ -9,15 +9,23 @@ module Zizq
|
|
|
9
9
|
# Typed wrapper around a job template — the fields shared between
|
|
10
10
|
# live jobs and cron entry job definitions.
|
|
11
11
|
class JobTemplate < Resource
|
|
12
|
-
def type
|
|
13
|
-
def queue
|
|
14
|
-
def priority
|
|
15
|
-
def payload
|
|
16
|
-
def retry_limit
|
|
17
|
-
def unique_key
|
|
12
|
+
def type = @data["type"] #: () -> String
|
|
13
|
+
def queue = @data["queue"] #: () -> String
|
|
14
|
+
def priority = @data["priority"] #: () -> Integer?
|
|
15
|
+
def payload = @data["payload"] #: () -> Hash[String, untyped]?
|
|
16
|
+
def retry_limit = @data["retry_limit"] #: () -> Integer?
|
|
17
|
+
def unique_key = @data["unique_key"] #: () -> String?
|
|
18
18
|
def unique_while = @data["unique_while"]&.to_sym #: () -> Zizq::unique_scope?
|
|
19
19
|
|
|
20
|
-
#
|
|
20
|
+
# Batching configuration for this job. Retutns `nil` for non-batched jobs.
|
|
21
|
+
def batch #: () -> Zizq::batch?
|
|
22
|
+
raw = @data["batch"]
|
|
23
|
+
return nil unless raw
|
|
24
|
+
|
|
25
|
+
{ key: raw["key"], when: raw["when"], fold: raw["fold"] }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Backoff configuration converted from the API format (ms) to the
|
|
21
29
|
# Ruby-idiomatic format (seconds), matching the Zizq::backoff type.
|
|
22
30
|
def backoff #: () -> Zizq::backoff?
|
|
23
31
|
raw = @data["backoff"]
|
|
@@ -30,7 +38,7 @@ module Zizq
|
|
|
30
38
|
}
|
|
31
39
|
end
|
|
32
40
|
|
|
33
|
-
# Retention configuration converted from the
|
|
41
|
+
# Retention configuration converted from the API format (ms) to the
|
|
34
42
|
# Ruby-idiomatic format (seconds), matching the Zizq::retention type.
|
|
35
43
|
def retention #: () -> Zizq::retention?
|
|
36
44
|
raw = @data["retention"]
|
data/lib/zizq/resources/page.rb
CHANGED
|
@@ -21,7 +21,8 @@ module Zizq
|
|
|
21
21
|
|
|
22
22
|
# Wrapped resource objects for this page.
|
|
23
23
|
def items #: () -> Array[T]
|
|
24
|
-
raise NotImplementedError,
|
|
24
|
+
raise NotImplementedError,
|
|
25
|
+
"#{self.class.name}#items must be implemented"
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
# Returns the underlying raw response hash.
|
|
@@ -27,10 +27,11 @@ module Zizq
|
|
|
27
27
|
|
|
28
28
|
# Omit the client from inspect output to reduce noise.
|
|
29
29
|
def inspect #: () -> String
|
|
30
|
-
ivars =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
ivars =
|
|
31
|
+
instance_variables
|
|
32
|
+
.reject { |v| v == :@client }
|
|
33
|
+
.map { |v| " #{v}=#{instance_variable_get(v).inspect}" }
|
|
34
|
+
.join
|
|
34
35
|
"#<#{self.class}#{ivars}>"
|
|
35
36
|
end
|
|
36
37
|
|
data/lib/zizq/resources.rb
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
module Zizq
|
|
7
7
|
module Resources
|
|
8
|
-
autoload :Resource,
|
|
9
|
-
autoload :JobTemplate,
|
|
10
|
-
autoload :Job,
|
|
11
|
-
autoload :ErrorRecord,
|
|
12
|
-
autoload :Page,
|
|
13
|
-
autoload :JobPage,
|
|
14
|
-
autoload :ErrorPage,
|
|
8
|
+
autoload :Resource, "zizq/resources/resource"
|
|
9
|
+
autoload :JobTemplate, "zizq/resources/job_template"
|
|
10
|
+
autoload :Job, "zizq/resources/job"
|
|
11
|
+
autoload :ErrorRecord, "zizq/resources/error_record"
|
|
12
|
+
autoload :Page, "zizq/resources/page"
|
|
13
|
+
autoload :JobPage, "zizq/resources/job_page"
|
|
14
|
+
autoload :ErrorPage, "zizq/resources/error_page"
|
|
15
15
|
autoload :ErrorEnumerator, "zizq/resources/error_enumerator"
|
|
16
|
-
autoload :CronGroup,
|
|
17
|
-
autoload :CronEntry,
|
|
16
|
+
autoload :CronGroup, "zizq/resources/cron_group"
|
|
17
|
+
autoload :CronEntry, "zizq/resources/cron_entry"
|
|
18
18
|
end
|
|
19
19
|
end
|
data/lib/zizq/router.rb
CHANGED
|
@@ -55,7 +55,8 @@ module Zizq
|
|
|
55
55
|
# route and no fallback. Caught by Zizq's normal worker error
|
|
56
56
|
# path, which nacks the job for retry (or dead-letters it once
|
|
57
57
|
# the retry limit is hit).
|
|
58
|
-
class UnknownJobType < Zizq::Error
|
|
58
|
+
class UnknownJobType < Zizq::Error
|
|
59
|
+
end
|
|
59
60
|
|
|
60
61
|
# @rbs &block: ?(self) [self: Router] -> void
|
|
61
62
|
def initialize(&block)
|
|
@@ -94,7 +95,7 @@ module Zizq
|
|
|
94
95
|
return @fallback.call(job) if @fallback
|
|
95
96
|
|
|
96
97
|
raise UnknownJobType,
|
|
97
|
-
|
|
98
|
+
"no handler registered for job type #{job.type.inspect}"
|
|
98
99
|
end
|
|
99
100
|
end
|
|
100
101
|
end
|
data/lib/zizq/test/client.rb
CHANGED
|
@@ -26,7 +26,8 @@ module Zizq
|
|
|
26
26
|
class Client < Zizq::Client
|
|
27
27
|
# Raised when test-mode code reaches an operation that isn't
|
|
28
28
|
# supported (queries, queue listing, worker streams, etc.).
|
|
29
|
-
class NotSupported < Zizq::Error
|
|
29
|
+
class NotSupported < Zizq::Error
|
|
30
|
+
end
|
|
30
31
|
|
|
31
32
|
# Length of a real scru128 id in its base-32 representation.
|
|
32
33
|
# Synthetic test ids are sized to match (`test` prefix + zero
|
|
@@ -39,10 +40,10 @@ module Zizq
|
|
|
39
40
|
# report. Test mode never retries — `in_flight` only ever
|
|
40
41
|
# transitions to `completed` or `dead`.
|
|
41
42
|
STATUS_SCHEDULED = "scheduled"
|
|
42
|
-
STATUS_READY
|
|
43
|
+
STATUS_READY = "ready"
|
|
43
44
|
STATUS_IN_FLIGHT = "in_flight"
|
|
44
45
|
STATUS_COMPLETED = "completed"
|
|
45
|
-
STATUS_DEAD
|
|
46
|
+
STATUS_DEAD = "dead"
|
|
46
47
|
|
|
47
48
|
# Default `filter:` lambda — passes every job. Named so the
|
|
48
49
|
# filter pipeline is always callable without nil-checking.
|
|
@@ -132,28 +133,33 @@ module Zizq
|
|
|
132
133
|
end
|
|
133
134
|
|
|
134
135
|
# @rbs override
|
|
135
|
-
def enqueue(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
def enqueue(
|
|
137
|
+
queue:,
|
|
138
|
+
type:,
|
|
139
|
+
payload:,
|
|
140
|
+
priority: nil,
|
|
141
|
+
ready_at: nil,
|
|
142
|
+
retry_limit: nil,
|
|
143
|
+
backoff: nil,
|
|
144
|
+
retention: nil,
|
|
145
|
+
unique_key: nil,
|
|
146
|
+
unique_while: nil,
|
|
147
|
+
batch: nil
|
|
148
|
+
)
|
|
149
|
+
req =
|
|
150
|
+
EnqueueRequest.new(
|
|
151
|
+
queue:,
|
|
152
|
+
type:,
|
|
153
|
+
payload: self.class.normalize_payload(payload),
|
|
154
|
+
priority:,
|
|
155
|
+
ready_at:,
|
|
156
|
+
retry_limit:,
|
|
157
|
+
backoff:,
|
|
158
|
+
retention:,
|
|
159
|
+
unique_key:,
|
|
160
|
+
unique_while:,
|
|
161
|
+
batch:
|
|
162
|
+
)
|
|
157
163
|
@mutex.synchronize { record_unsynchronized(req) }.job
|
|
158
164
|
end
|
|
159
165
|
|
|
@@ -161,18 +167,20 @@ module Zizq
|
|
|
161
167
|
def enqueue_bulk(jobs:)
|
|
162
168
|
@mutex.synchronize do
|
|
163
169
|
jobs.map do |params|
|
|
164
|
-
req =
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
req =
|
|
171
|
+
EnqueueRequest.new(
|
|
172
|
+
queue: params[:queue],
|
|
173
|
+
type: params[:type],
|
|
174
|
+
payload: self.class.normalize_payload(params[:payload]),
|
|
175
|
+
priority: params[:priority],
|
|
176
|
+
ready_at: params[:ready_at],
|
|
177
|
+
retry_limit: params[:retry_limit],
|
|
178
|
+
backoff: params[:backoff],
|
|
179
|
+
retention: params[:retention],
|
|
180
|
+
unique_key: params[:unique_key],
|
|
181
|
+
unique_while: params[:unique_while],
|
|
182
|
+
batch: params[:batch]
|
|
183
|
+
)
|
|
176
184
|
record_unsynchronized(req).job
|
|
177
185
|
end
|
|
178
186
|
end
|
|
@@ -202,7 +210,7 @@ module Zizq
|
|
|
202
210
|
Kernel.raise(
|
|
203
211
|
NotSupported,
|
|
204
212
|
"Zizq::Test::Client##{method_name} is not supported in test mode. " \
|
|
205
|
-
|
|
213
|
+
"Test mode buffers enqueues only — point at a real server, or stub the call."
|
|
206
214
|
)
|
|
207
215
|
end
|
|
208
216
|
end
|
|
@@ -227,15 +235,20 @@ module Zizq
|
|
|
227
235
|
"priority" => req.priority,
|
|
228
236
|
"ready_at" => ready_at_ms,
|
|
229
237
|
"retry_limit" => req.retry_limit,
|
|
230
|
-
"status" => ready_at_ms > now_ms ? STATUS_SCHEDULED : STATUS_READY
|
|
238
|
+
"status" => ready_at_ms > now_ms ? STATUS_SCHEDULED : STATUS_READY
|
|
231
239
|
}
|
|
232
|
-
entry =
|
|
240
|
+
entry =
|
|
241
|
+
Entry.new(
|
|
242
|
+
request: req,
|
|
243
|
+
job: Resources::Job.new(self, data),
|
|
244
|
+
data: data
|
|
245
|
+
)
|
|
233
246
|
@entries << entry
|
|
234
247
|
entry
|
|
235
248
|
end
|
|
236
249
|
|
|
237
250
|
def synthetic_id(counter) #: (Integer) -> String
|
|
238
|
-
"#{ID_PREFIX}#{counter.to_s.rjust(ID_LENGTH - ID_PREFIX.length,
|
|
251
|
+
"#{ID_PREFIX}#{counter.to_s.rjust(ID_LENGTH - ID_PREFIX.length, "0")}"
|
|
239
252
|
end
|
|
240
253
|
|
|
241
254
|
public
|
|
@@ -267,20 +280,22 @@ module Zizq
|
|
|
267
280
|
# truthy to keep. Defaults to `PASS_ALL_FILTER`.
|
|
268
281
|
#
|
|
269
282
|
# `only_*` and `except_*` AND together with the predicate.
|
|
270
|
-
def apply_filters(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
283
|
+
def apply_filters(
|
|
284
|
+
entries,
|
|
285
|
+
only_queues: nil,
|
|
286
|
+
except_queues: nil,
|
|
287
|
+
only_types: nil,
|
|
288
|
+
except_types: nil,
|
|
289
|
+
filter: PASS_ALL_FILTER
|
|
290
|
+
) #: (Array[Entry], **untyped) -> Array[Entry]
|
|
291
|
+
only_queues = normalize_filter(only_queues)
|
|
277
292
|
except_queues = normalize_filter(except_queues)
|
|
278
|
-
only_types
|
|
279
|
-
except_types
|
|
293
|
+
only_types = normalize_filter(only_types)
|
|
294
|
+
except_types = normalize_filter(except_types)
|
|
280
295
|
|
|
281
296
|
entries.select do |entry|
|
|
282
297
|
queue = entry.data["queue"] #: String
|
|
283
|
-
type
|
|
298
|
+
type = entry.data["type"] #: String
|
|
284
299
|
|
|
285
300
|
(only_queues.empty? || only_queues.include?(queue)) &&
|
|
286
301
|
(except_queues.empty? || !except_queues.include?(queue)) &&
|
|
@@ -313,9 +328,12 @@ module Zizq
|
|
|
313
328
|
|
|
314
329
|
def runnable?(entry, now_ms) #: (Entry, Integer) -> bool
|
|
315
330
|
case entry.data["status"]
|
|
316
|
-
when STATUS_READY
|
|
317
|
-
|
|
318
|
-
|
|
331
|
+
when STATUS_READY
|
|
332
|
+
true
|
|
333
|
+
when STATUS_SCHEDULED
|
|
334
|
+
entry.data["ready_at"] <= now_ms
|
|
335
|
+
else
|
|
336
|
+
false
|
|
319
337
|
end
|
|
320
338
|
end
|
|
321
339
|
|
|
@@ -323,9 +341,12 @@ module Zizq
|
|
|
323
341
|
# Strings. Class names match the API's `type` string.
|
|
324
342
|
def normalize_filter(value) #: ((String | Class | Array[String | Class])?) -> Array[String]
|
|
325
343
|
case value
|
|
326
|
-
when nil
|
|
327
|
-
|
|
328
|
-
|
|
344
|
+
when nil
|
|
345
|
+
[]
|
|
346
|
+
when Array
|
|
347
|
+
value.map { |x| x.to_s }
|
|
348
|
+
else
|
|
349
|
+
[value.to_s]
|
|
329
350
|
end
|
|
330
351
|
end
|
|
331
352
|
|
|
@@ -340,7 +361,7 @@ module Zizq
|
|
|
340
361
|
begin
|
|
341
362
|
Zizq.configuration.dequeue_middleware.call(entry.job)
|
|
342
363
|
entry.data["status"] = STATUS_COMPLETED
|
|
343
|
-
rescue
|
|
364
|
+
rescue StandardError
|
|
344
365
|
entry.data["status"] = STATUS_DEAD
|
|
345
366
|
raise
|
|
346
367
|
end
|
data/lib/zizq/test.rb
CHANGED
|
@@ -60,7 +60,7 @@ module Zizq
|
|
|
60
60
|
def self.client #: () -> Client
|
|
61
61
|
unless Zizq.configuration.test_mode
|
|
62
62
|
raise Client::NotSupported,
|
|
63
|
-
|
|
63
|
+
"Zizq.configuration.test_mode is not enabled; Zizq::Test.client has nothing to manage."
|
|
64
64
|
end
|
|
65
65
|
Zizq.client #: Client
|
|
66
66
|
end
|
|
@@ -141,15 +141,15 @@ module Zizq
|
|
|
141
141
|
|
|
142
142
|
unless job_class.respond_to?(:zizq_serialize)
|
|
143
143
|
raise ArgumentError,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
"#{job_class} doesn't implement zizq_serialize — " \
|
|
145
|
+
"include Zizq::Job or extend Zizq::ActiveJobConfig, " \
|
|
146
|
+
"or use Zizq::Test.enqueued_raw? for raw enqueues."
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
expected = job_class.zizq_serialize(*args, **kwargs)
|
|
150
|
-
client
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
client
|
|
151
|
+
.enqueued_jobs(only_types: type)
|
|
152
|
+
.count { |job| payloads_equivalent?(expected, job.payload) }
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
# Was a raw job (queue + type + payload) enqueued? Each kwarg is
|
|
@@ -167,7 +167,7 @@ module Zizq
|
|
|
167
167
|
def self.enqueued_raw_count(queue: nil, type: nil, payload: nil) #: (?queue: String?, ?type: String?, ?payload: untyped) -> Integer
|
|
168
168
|
filters = {}
|
|
169
169
|
filters[:only_queues] = queue if queue
|
|
170
|
-
filters[:only_types]
|
|
170
|
+
filters[:only_types] = type if type
|
|
171
171
|
unless payload.nil?
|
|
172
172
|
# Normalize the assertion-side payload the same way enqueue
|
|
173
173
|
# normalizes the buffered one, so symbol-keyed test payloads
|
|
@@ -18,10 +18,11 @@ module Zizq
|
|
|
18
18
|
# All values may be PEM-encoded strings or file paths.
|
|
19
19
|
#
|
|
20
20
|
# Note: Mutual TLS support requires a Zizq Pro license on the server.
|
|
21
|
-
TlsConfiguration =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
TlsConfiguration =
|
|
22
|
+
Struct.new(
|
|
23
|
+
:ca, #: String?
|
|
24
|
+
:client_cert, #: String?
|
|
25
|
+
:client_key, #: String?
|
|
26
|
+
keyword_init: true
|
|
27
|
+
)
|
|
27
28
|
end
|
data/lib/zizq/version.rb
CHANGED