zizq 0.2.1 → 0.3.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 +19 -0
- data/lib/zizq/bulk_enqueue.rb +1 -1
- data/lib/zizq/client.rb +205 -7
- data/lib/zizq/crontab.rb +263 -0
- data/lib/zizq/crontab_builder.rb +52 -0
- data/lib/zizq/crontab_entry.rb +182 -0
- data/lib/zizq/crontab_entry_builder.rb +133 -0
- data/lib/zizq/enqueue_with.rb +1 -1
- data/lib/zizq/job.rb +6 -2
- data/lib/zizq/query.rb +2 -2
- data/lib/zizq/resources/cron_entry.rb +27 -0
- data/lib/zizq/resources/cron_group.rb +23 -0
- data/lib/zizq/resources/job.rb +4 -36
- data/lib/zizq/resources/job_template.rb +46 -0
- data/lib/zizq/resources.rb +3 -0
- data/lib/zizq/version.rb +1 -1
- data/lib/zizq.rb +106 -18
- data/sig/generated/zizq/bulk_enqueue.rbs +2 -2
- data/sig/generated/zizq/client.rbs +115 -0
- data/sig/generated/zizq/crontab.rbs +141 -0
- data/sig/generated/zizq/crontab_builder.rbs +35 -0
- data/sig/generated/zizq/crontab_entry.rbs +98 -0
- data/sig/generated/zizq/crontab_entry_builder.rbs +92 -0
- data/sig/generated/zizq/enqueue_with.rbs +2 -2
- data/sig/generated/zizq/query.rbs +4 -4
- data/sig/generated/zizq/resources/cron_entry.rbs +29 -0
- data/sig/generated/zizq/resources/cron_group.rbs +21 -0
- data/sig/generated/zizq/resources/job.rbs +4 -26
- data/sig/generated/zizq/resources/job_template.rbs +31 -0
- data/sig/generated/zizq.rbs +78 -4
- data/sig/zizq.rbs +24 -17
- metadata +20 -6
data/lib/zizq.rb
CHANGED
|
@@ -12,20 +12,24 @@ require_relative "zizq/configuration"
|
|
|
12
12
|
autoload :MessagePack, "msgpack"
|
|
13
13
|
|
|
14
14
|
module Zizq
|
|
15
|
-
autoload :AckProcessor,
|
|
16
|
-
autoload :ActiveJobConfig,
|
|
17
|
-
autoload :Backoff,
|
|
18
|
-
autoload :BulkEnqueue,
|
|
19
|
-
autoload :Client,
|
|
20
|
-
autoload :
|
|
21
|
-
autoload :
|
|
22
|
-
autoload :
|
|
23
|
-
autoload :
|
|
24
|
-
autoload :
|
|
25
|
-
autoload :
|
|
26
|
-
autoload :
|
|
27
|
-
autoload :
|
|
28
|
-
autoload :
|
|
15
|
+
autoload :AckProcessor, "zizq/ack_processor"
|
|
16
|
+
autoload :ActiveJobConfig, "zizq/active_job_config"
|
|
17
|
+
autoload :Backoff, "zizq/backoff"
|
|
18
|
+
autoload :BulkEnqueue, "zizq/bulk_enqueue"
|
|
19
|
+
autoload :Client, "zizq/client"
|
|
20
|
+
autoload :Crontab, "zizq/crontab"
|
|
21
|
+
autoload :CrontabBuilder, "zizq/crontab_builder"
|
|
22
|
+
autoload :CrontabEntry, "zizq/crontab_entry"
|
|
23
|
+
autoload :CrontabEntryBuilder, "zizq/crontab_entry_builder"
|
|
24
|
+
autoload :EnqueueRequest, "zizq/enqueue_request"
|
|
25
|
+
autoload :EnqueueWith, "zizq/enqueue_with"
|
|
26
|
+
autoload :Job, "zizq/job"
|
|
27
|
+
autoload :JobConfig, "zizq/job_config"
|
|
28
|
+
autoload :Middleware, "zizq/middleware"
|
|
29
|
+
autoload :Lifecycle, "zizq/lifecycle"
|
|
30
|
+
autoload :Query, "zizq/query"
|
|
31
|
+
autoload :Resources, "zizq/resources"
|
|
32
|
+
autoload :Worker, "zizq/worker"
|
|
29
33
|
|
|
30
34
|
# Sentinel indicating a field should not be included in the request.
|
|
31
35
|
# Used as the default for update parameters.
|
|
@@ -59,7 +63,9 @@ module Zizq
|
|
|
59
63
|
def configure #: () { (Configuration) -> void } -> void
|
|
60
64
|
yield configuration
|
|
61
65
|
ensure
|
|
62
|
-
|
|
66
|
+
# shared client is potentially stale
|
|
67
|
+
@client&.close
|
|
68
|
+
@client = nil
|
|
63
69
|
end
|
|
64
70
|
|
|
65
71
|
# Returns a shared client instance built from the global configuration.
|
|
@@ -114,6 +120,88 @@ module Zizq
|
|
|
114
120
|
Query.new(...)
|
|
115
121
|
end
|
|
116
122
|
|
|
123
|
+
# Return a list of all available Crontab schedules.
|
|
124
|
+
def crontabs #: () -> Array[String]
|
|
125
|
+
Zizq.client.list_cron_groups
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Define (or redefine) a Crontab schedule.
|
|
129
|
+
#
|
|
130
|
+
# This requires a Pro license on the Zizq server.
|
|
131
|
+
#
|
|
132
|
+
# Crontabs are used to define collections of recurring jobs that run on a
|
|
133
|
+
# specified schedule, such as at 2am on every Monday. Each entry on the
|
|
134
|
+
# Crontab is a single job enqueue, which the Zizq server automatically
|
|
135
|
+
# triggers at the correct point in time. Zizq uses standard Cron expression
|
|
136
|
+
# syntax (with support for seconds via 6-fields) to define entries.
|
|
137
|
+
#
|
|
138
|
+
# This is designed to be idempotent. You can define a schedule somewhere in
|
|
139
|
+
# your application startup process (after `Zizq.configure`) and it doesn't
|
|
140
|
+
# matter if multiple process all define the same schedule. Zizq is smart
|
|
141
|
+
# enough to handle this correctly.
|
|
142
|
+
#
|
|
143
|
+
# Entire schedules, and individual entries on a schedule, can be paused and
|
|
144
|
+
# resumed.
|
|
145
|
+
#
|
|
146
|
+
# By default schedules operate in the system time zone of the Zizq server
|
|
147
|
+
# but an explicit IANA timezone name can be specified when defining the
|
|
148
|
+
# Crontab.
|
|
149
|
+
#
|
|
150
|
+
# This method sends exactly *one* request to the Zizq server upon
|
|
151
|
+
# completion of the block. Any existing entries are retained. Any new
|
|
152
|
+
# entries are added, any absent entries are removed, and any modified
|
|
153
|
+
# entries are replaced. In short, whatever the block defines is what the
|
|
154
|
+
# entire resulting Crontab schedule will look like.
|
|
155
|
+
#
|
|
156
|
+
# Zizq.define_crontab("example", timezone: "Europe/Rome") do |cron|
|
|
157
|
+
# cron.define_entry(
|
|
158
|
+
# "refresh_data_warehose",
|
|
159
|
+
# "*/15 * * * *"
|
|
160
|
+
# ).enqueue(RefreshDataWarehoseJob, incremental: true)
|
|
161
|
+
#
|
|
162
|
+
# cron.define_entry(
|
|
163
|
+
# "expire_acess_tokens",
|
|
164
|
+
# "*/10 * * * * *"
|
|
165
|
+
# ).enqueue_raw(
|
|
166
|
+
# queue: "identity-server",
|
|
167
|
+
# type: "expire_access_tokens",
|
|
168
|
+
# priority: 100,
|
|
169
|
+
# payload: {},
|
|
170
|
+
# )
|
|
171
|
+
# end
|
|
172
|
+
#
|
|
173
|
+
# When jobs are pushed to the queue at their execution time, Zizq handles
|
|
174
|
+
# this atomically, so there is no risk of a duplicate enqueue for the same
|
|
175
|
+
# schedule tick. However, if you have long-running jobs that should not be
|
|
176
|
+
# permitted to overlap, such as in the case your schedule runs every 10
|
|
177
|
+
# seconds but jobs can take 30 seconds to execute, you should consider
|
|
178
|
+
# using unique jobs.
|
|
179
|
+
#
|
|
180
|
+
# @rbs name: String
|
|
181
|
+
# @rbs timezone: String?
|
|
182
|
+
# @rbs paused: bool?
|
|
183
|
+
# @rbs &block: (Zizq::CrontabBuilder) -> void
|
|
184
|
+
# @rbs return: Zizq::Crontab
|
|
185
|
+
def define_crontab(name, timezone: nil, paused: nil, &block)
|
|
186
|
+
crontab = Crontab.new(name)
|
|
187
|
+
crontab.redefine(timezone:, paused:, &block)
|
|
188
|
+
crontab
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Obtain a handle for the given Crontab schedule.
|
|
192
|
+
#
|
|
193
|
+
# This is a lazy operation. The schedule data is only fetched from the Zizq
|
|
194
|
+
# server upon first accessing data within the schedule.
|
|
195
|
+
#
|
|
196
|
+
# Zizq.crontab("default").paused?
|
|
197
|
+
# Zizq.crontab("default").resume!
|
|
198
|
+
#
|
|
199
|
+
# @rbs name: String
|
|
200
|
+
# @rbs return: Zizq::Crontab
|
|
201
|
+
def crontab(name)
|
|
202
|
+
Crontab.new(name)
|
|
203
|
+
end
|
|
204
|
+
|
|
117
205
|
# Enqueue a job by class with positional and keyword arguments.
|
|
118
206
|
#
|
|
119
207
|
# By default all arguments are serialized as JSON, which means hashes with
|
|
@@ -149,7 +237,7 @@ module Zizq
|
|
|
149
237
|
# end
|
|
150
238
|
# end
|
|
151
239
|
#
|
|
152
|
-
# @rbs job_class: Class & Zizq::
|
|
240
|
+
# @rbs job_class: Class & Zizq::JobConfig
|
|
153
241
|
# @rbs args: Array[untyped]
|
|
154
242
|
# @rbs kwargs: Hash[Symbol, untyped]
|
|
155
243
|
# @rbs &block: ?(EnqueueRequest) -> void
|
|
@@ -247,7 +335,7 @@ module Zizq
|
|
|
247
335
|
# @api private
|
|
248
336
|
# Build an EnqueueRequest for a single job class enqueue.
|
|
249
337
|
#
|
|
250
|
-
# @rbs job_class: Class & Zizq::
|
|
338
|
+
# @rbs job_class: Class & Zizq::JobConfig
|
|
251
339
|
# @rbs args: Array[untyped]
|
|
252
340
|
# @rbs kwargs: Hash[Symbol, untyped]
|
|
253
341
|
# @rbs &block: ?(EnqueueRequest) -> void
|
|
@@ -257,7 +345,7 @@ module Zizq
|
|
|
257
345
|
raise ArgumentError, "#{job_class.inspect} must include Zizq::Job or extend Zizq::ActiveJobConfig"
|
|
258
346
|
end
|
|
259
347
|
|
|
260
|
-
zizq_job_class = job_class #: Zizq::
|
|
348
|
+
zizq_job_class = job_class #: Zizq::JobConfig
|
|
261
349
|
req = zizq_job_class.zizq_enqueue_request(*args, **kwargs)
|
|
262
350
|
yield req if block_given?
|
|
263
351
|
req
|
|
@@ -16,12 +16,12 @@ module Zizq
|
|
|
16
16
|
# Collect a job class enqueue. Accepts the same arguments as
|
|
17
17
|
# `Zizq.enqueue`.
|
|
18
18
|
#
|
|
19
|
-
# @rbs job_class: Class & Zizq::
|
|
19
|
+
# @rbs job_class: Class & Zizq::JobConfig
|
|
20
20
|
# @rbs args: Array[untyped]
|
|
21
21
|
# @rbs kwargs: Hash[Symbol, untyped]
|
|
22
22
|
# @rbs &block: ?(EnqueueRequest) -> void
|
|
23
23
|
# @rbs return: void
|
|
24
|
-
def enqueue: (Class & Zizq::
|
|
24
|
+
def enqueue: (Class & Zizq::JobConfig job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> void
|
|
25
25
|
|
|
26
26
|
# Collect a raw enqueue. Accepts the same arguments as
|
|
27
27
|
# `Zizq.enqueue_raw`.
|
|
@@ -196,6 +196,90 @@ module Zizq
|
|
|
196
196
|
# List all distinct queue names on the server.
|
|
197
197
|
def get_queues: () -> untyped
|
|
198
198
|
|
|
199
|
+
# List all cron group names.
|
|
200
|
+
#
|
|
201
|
+
# @rbs return: Array[String]
|
|
202
|
+
def list_cron_groups: () -> Array[String]
|
|
203
|
+
|
|
204
|
+
# Fetch a cron group and all its entries.
|
|
205
|
+
#
|
|
206
|
+
# @rbs name: String
|
|
207
|
+
# @rbs return: Resources::CronGroup
|
|
208
|
+
def get_cron_group: (String name) -> Resources::CronGroup
|
|
209
|
+
|
|
210
|
+
# Create or replace an entire cron group.
|
|
211
|
+
#
|
|
212
|
+
# Entries not present in the request are removed. Entries with unchanged
|
|
213
|
+
# expressions preserve their scheduling state.
|
|
214
|
+
#
|
|
215
|
+
# @rbs name: String
|
|
216
|
+
# @rbs paused: bool?
|
|
217
|
+
# @rbs entries: Array[Zizq::cron_entry_params]
|
|
218
|
+
# @rbs return: Resources::CronGroup
|
|
219
|
+
def replace_cron_group: (String name, ?paused: bool?, ?entries: Array[Zizq::cron_entry_params]) -> Resources::CronGroup
|
|
220
|
+
|
|
221
|
+
# Update group-level fields (currently just pause/unpause).
|
|
222
|
+
#
|
|
223
|
+
# @rbs name: String
|
|
224
|
+
# @rbs paused: bool?
|
|
225
|
+
# @rbs return: Resources::CronGroup
|
|
226
|
+
def update_cron_group: (String name, ?paused: bool?) -> Resources::CronGroup
|
|
227
|
+
|
|
228
|
+
# Delete a cron group and all its entries.
|
|
229
|
+
#
|
|
230
|
+
# @rbs name: String
|
|
231
|
+
# @rbs return: void
|
|
232
|
+
def delete_cron_group: (String name) -> void
|
|
233
|
+
|
|
234
|
+
# Fetch a single cron entry.
|
|
235
|
+
#
|
|
236
|
+
# @rbs group: String
|
|
237
|
+
# @rbs entry: String
|
|
238
|
+
# @rbs return: Resources::CronEntry
|
|
239
|
+
def get_cron_group_entry: (String group, String entry) -> Resources::CronEntry
|
|
240
|
+
|
|
241
|
+
# Add a single entry to a cron group (creates the group if needed).
|
|
242
|
+
#
|
|
243
|
+
# Raises a ClientError (409 Conflict) if an entry with the same name
|
|
244
|
+
# already exists.
|
|
245
|
+
#
|
|
246
|
+
# @rbs group: String
|
|
247
|
+
# @rbs name: String
|
|
248
|
+
# @rbs expression: String
|
|
249
|
+
# @rbs job: Zizq::cron_job_params
|
|
250
|
+
# @rbs timezone: String?
|
|
251
|
+
# @rbs paused: bool?
|
|
252
|
+
# @rbs return: Resources::CronEntry
|
|
253
|
+
def add_cron_group_entry: (String group, name: String, expression: String, job: Zizq::cron_job_params, ?timezone: String?, ?paused: bool?) -> Resources::CronEntry
|
|
254
|
+
|
|
255
|
+
# Create or replace a single cron entry.
|
|
256
|
+
#
|
|
257
|
+
# Preserves scheduling state if the expression is unchanged.
|
|
258
|
+
#
|
|
259
|
+
# @rbs group: String
|
|
260
|
+
# @rbs entry: String
|
|
261
|
+
# @rbs expression: String
|
|
262
|
+
# @rbs job: Zizq::cron_job_params
|
|
263
|
+
# @rbs timezone: String?
|
|
264
|
+
# @rbs paused: bool?
|
|
265
|
+
# @rbs return: Resources::CronEntry
|
|
266
|
+
def replace_cron_group_entry: (String group, String entry, expression: String, job: Zizq::cron_job_params, ?timezone: String?, ?paused: bool?) -> Resources::CronEntry
|
|
267
|
+
|
|
268
|
+
# Update entry-level fields (currently just pause/unpause).
|
|
269
|
+
#
|
|
270
|
+
# @rbs group: String
|
|
271
|
+
# @rbs entry: String
|
|
272
|
+
# @rbs paused: bool
|
|
273
|
+
# @rbs return: Resources::CronEntry
|
|
274
|
+
def update_cron_group_entry: (String group, String entry, paused: bool) -> Resources::CronEntry
|
|
275
|
+
|
|
276
|
+
# Delete a single cron entry.
|
|
277
|
+
#
|
|
278
|
+
# @rbs group: String
|
|
279
|
+
# @rbs entry: String
|
|
280
|
+
# @rbs return: void
|
|
281
|
+
def delete_cron_group_entry: (String group, String entry) -> void
|
|
282
|
+
|
|
199
283
|
# Mark a job as successfully completed (ack).
|
|
200
284
|
#
|
|
201
285
|
# If this method (or [`#report_failure`]) is not called upon job
|
|
@@ -330,9 +414,38 @@ module Zizq
|
|
|
330
414
|
|
|
331
415
|
private
|
|
332
416
|
|
|
417
|
+
# URL-encode a single path segment.
|
|
418
|
+
def enc: (untyped value) -> untyped
|
|
419
|
+
|
|
333
420
|
# Build a relative path with optional query parameters.
|
|
334
421
|
def build_path: (untyped path, ?params: untyped) -> untyped
|
|
335
422
|
|
|
423
|
+
# Validate and build a cron entry body from keyword arguments.
|
|
424
|
+
#
|
|
425
|
+
# @rbs name: String
|
|
426
|
+
# @rbs expression: String
|
|
427
|
+
# @rbs job: Zizq::cron_job_params
|
|
428
|
+
# @rbs timezone: String?
|
|
429
|
+
# @rbs paused: bool?
|
|
430
|
+
# @rbs return: Hash[Symbol, untyped]
|
|
431
|
+
def build_cron_entry: (?name: String, ?expression: String, ?job: Zizq::cron_job_params, ?timezone: String?, ?paused: bool?) -> Hash[Symbol, untyped]
|
|
432
|
+
|
|
433
|
+
# Validate and build a cron job template from keyword arguments.
|
|
434
|
+
#
|
|
435
|
+
# Uses keyword args so that unknown keys raise ArgumentError.
|
|
436
|
+
#
|
|
437
|
+
# @rbs type: String
|
|
438
|
+
# @rbs queue: String
|
|
439
|
+
# @rbs payload: untyped
|
|
440
|
+
# @rbs priority: Integer?
|
|
441
|
+
# @rbs retry_limit: Integer?
|
|
442
|
+
# @rbs backoff: Zizq::backoff?
|
|
443
|
+
# @rbs retention: Zizq::retention?
|
|
444
|
+
# @rbs unique_key: String?
|
|
445
|
+
# @rbs unique_while: Zizq::unique_scope?
|
|
446
|
+
# @rbs return: Hash[Symbol, untyped]
|
|
447
|
+
def build_cron_job: (?type: String, ?queue: String, ?payload: untyped, ?priority: Integer?, ?retry_limit: Integer?, ?backoff: Zizq::backoff?, ?retention: Zizq::retention?, ?unique_key: String?, ?unique_while: Zizq::unique_scope?) -> Hash[Symbol, untyped]
|
|
448
|
+
|
|
336
449
|
# Validate and normalize filter parameters for bulk operations.
|
|
337
450
|
#
|
|
338
451
|
# Uses keyword arguments so that unknown keys raise ArgumentError.
|
|
@@ -419,6 +532,8 @@ module Zizq
|
|
|
419
532
|
|
|
420
533
|
def raw_post: (untyped path) -> untyped
|
|
421
534
|
|
|
535
|
+
def put: (untyped path, untyped body) -> untyped
|
|
536
|
+
|
|
422
537
|
def delete: (untyped path, ?params: untyped) -> untyped
|
|
423
538
|
|
|
424
539
|
def patch: (untyped path, untyped body, ?params: untyped) -> untyped
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Generated from lib/zizq/crontab.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
# Represents a Crontab schedule defined on the Zizq server.
|
|
5
|
+
#
|
|
6
|
+
# This requires a Pro license on the Zizq server.
|
|
7
|
+
#
|
|
8
|
+
# The actual data is lazily fetched when first accessed.
|
|
9
|
+
#
|
|
10
|
+
# Crontabs are used to define collections of recurring jobs that run on a
|
|
11
|
+
# specified schedule, such as at 2am on every Monday. Each entry on the
|
|
12
|
+
# Crontab is a single job enqueue, which the Zizq server automatically
|
|
13
|
+
# triggers at the correct point in time. Zizq uses standard Cron expression
|
|
14
|
+
# syntax (with support for seconds via 6-fields) to define entries.
|
|
15
|
+
#
|
|
16
|
+
# Entire schedules, and individual entries on a schedule, can be paused and
|
|
17
|
+
# resumed.
|
|
18
|
+
#
|
|
19
|
+
# By default schedules operate in the system time zone of the Zizq server
|
|
20
|
+
# but an explicit IANA timezone name can be specified when defining the
|
|
21
|
+
# Crontab.
|
|
22
|
+
class Crontab
|
|
23
|
+
# The name of the cron group that this schedule is backed by.
|
|
24
|
+
attr_reader name: String
|
|
25
|
+
|
|
26
|
+
# True if this schedule is paused.
|
|
27
|
+
#
|
|
28
|
+
# When paused, the scheduler continues to run but does not enqueue any jobs
|
|
29
|
+
# and only advances the timer.
|
|
30
|
+
attr_writer paused: bool?
|
|
31
|
+
|
|
32
|
+
# Initialize the Crontab with the given group name.
|
|
33
|
+
#
|
|
34
|
+
# @rbs name: String
|
|
35
|
+
def initialize: (String name) -> untyped
|
|
36
|
+
|
|
37
|
+
# Fetch data from the Zizq server if not already fetched.
|
|
38
|
+
#
|
|
39
|
+
# Once fetched, this method becomes a no-op, unless #clear is called to
|
|
40
|
+
# remove the fetched data.
|
|
41
|
+
def materialize: () -> untyped
|
|
42
|
+
|
|
43
|
+
# Clear materialized data that was fetched from the Zizq server.
|
|
44
|
+
#
|
|
45
|
+
# This triggers a refetch when the data is next accessed.
|
|
46
|
+
def clear: () -> untyped
|
|
47
|
+
|
|
48
|
+
# Delete this entire Crontab schedule and its entries.
|
|
49
|
+
def delete!: () -> untyped
|
|
50
|
+
|
|
51
|
+
# Pause this entire Crontab schedule.
|
|
52
|
+
#
|
|
53
|
+
# All entries will stop enqueueing jobs, but the server continues to
|
|
54
|
+
# advance the schedule until it is resumed.
|
|
55
|
+
def pause!: () -> untyped
|
|
56
|
+
|
|
57
|
+
# Resume this Crontab schedule if it is currently paused.
|
|
58
|
+
#
|
|
59
|
+
# Individual entries that are paused will remain paused.
|
|
60
|
+
def resume!: () -> untyped
|
|
61
|
+
|
|
62
|
+
# Check if this schedule is currently paused.
|
|
63
|
+
def paused: () -> untyped
|
|
64
|
+
|
|
65
|
+
# Check if this schedule is currently paused.
|
|
66
|
+
#
|
|
67
|
+
# Alias of #paused.
|
|
68
|
+
def paused?: () -> untyped
|
|
69
|
+
|
|
70
|
+
# Return the timestamp at which this Crontab schedule was last paused.
|
|
71
|
+
def paused_at: () -> untyped
|
|
72
|
+
|
|
73
|
+
# Return the timestamp at which this Crontab schedule was last resumed.
|
|
74
|
+
def resumed_at: () -> untyped
|
|
75
|
+
|
|
76
|
+
# Return a Hash of Zizq::CrontabEntry instances keyed by their names.
|
|
77
|
+
#
|
|
78
|
+
# Each entry specifies the cron expression at which it executes,
|
|
79
|
+
# information about when it last/next enqueued a job, and details of the
|
|
80
|
+
# job that the entry enqueues.
|
|
81
|
+
def entries: () -> untyped
|
|
82
|
+
|
|
83
|
+
# Redefine (replace) this Crontab schedule with another.
|
|
84
|
+
#
|
|
85
|
+
# This is equivalent to calling `Zizq.define_crontab` and is idempotent
|
|
86
|
+
# when given the same schedule more than once.
|
|
87
|
+
#
|
|
88
|
+
# @rbs ?timezone: String?
|
|
89
|
+
# @rbs ?paused: bool?
|
|
90
|
+
# @rbs &block: (Zizq::CrontabBuilder) -> void
|
|
91
|
+
# @rbs return: self
|
|
92
|
+
def redefine: (?timezone: untyped, ?paused: untyped) { (Zizq::CrontabBuilder) -> void } -> self
|
|
93
|
+
|
|
94
|
+
# Return a handle for the specified Zizq::CrontabEntry.
|
|
95
|
+
#
|
|
96
|
+
# The entry can be paused or resumed is isolation, can be deleted entirely
|
|
97
|
+
# or can be redefined (replaced) with another entry.
|
|
98
|
+
#
|
|
99
|
+
# @rbs name: String
|
|
100
|
+
# @rbs return: Zizq::CrontabEntry
|
|
101
|
+
def entry: (String name) -> Zizq::CrontabEntry
|
|
102
|
+
|
|
103
|
+
# Define (or redefine) an entry with this Crontab schedule.
|
|
104
|
+
#
|
|
105
|
+
# Defining the same entry more than once is idempotent. If the entry does
|
|
106
|
+
# not exist, it is added to the schedule. If the entry already exists, it
|
|
107
|
+
# replaces the current entry.
|
|
108
|
+
#
|
|
109
|
+
# The return value is a Zizq::CrontabEntryBuilder instance, on which the
|
|
110
|
+
# caller must call one of the enqueue methods (`enqueue`, `enqueue_raw`,
|
|
111
|
+
# optionally chained onto `enqueue_with`, exactly the same as a regular job
|
|
112
|
+
# enqueue).
|
|
113
|
+
#
|
|
114
|
+
# All enqueue options are supported *except* `delay` and `ready_at` which
|
|
115
|
+
# make no sense for recurring jobs.
|
|
116
|
+
#
|
|
117
|
+
# Bulk enqueues are not supported.
|
|
118
|
+
#
|
|
119
|
+
# crontab.define_entry(
|
|
120
|
+
# "refresh_data_warehose",
|
|
121
|
+
# "*/15 * * * *",
|
|
122
|
+
# ).enqueue(RefreshDataWarehoseJob, incremental: true)
|
|
123
|
+
#
|
|
124
|
+
# @rbs name: String
|
|
125
|
+
# @rbs expression: String
|
|
126
|
+
# @rbs timezone: String?
|
|
127
|
+
# @rbs paused: bool?
|
|
128
|
+
# @rbs return: Zizq::CrontabEntryBuilder
|
|
129
|
+
def define_entry: (String name, String expression, ?timezone: String?, ?paused: bool?) -> Zizq::CrontabEntryBuilder
|
|
130
|
+
|
|
131
|
+
private
|
|
132
|
+
|
|
133
|
+
# @rbs result: Zizq::Resources::CronGroup
|
|
134
|
+
# @rbs return: self
|
|
135
|
+
def materialize_with: (Zizq::Resources::CronGroup result) -> self
|
|
136
|
+
|
|
137
|
+
# @rbs result: Zizq::Resources::CronEntry
|
|
138
|
+
# @rbs return: Zizq::CrontabEntry
|
|
139
|
+
def materialize_entry_with: (Zizq::Resources::CronEntry result) -> Zizq::CrontabEntry
|
|
140
|
+
end
|
|
141
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Generated from lib/zizq/crontab_builder.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
# Builder used to configure a Zizq::Crontab instance.
|
|
5
|
+
#
|
|
6
|
+
# Instances of this class are returned from `Zizq.define_crontab`. See
|
|
7
|
+
# documentation for that method for usage.
|
|
8
|
+
class CrontabBuilder
|
|
9
|
+
# The Crontab instance that this builder configures.
|
|
10
|
+
attr_reader target: Zizq::Crontab
|
|
11
|
+
|
|
12
|
+
# Optional timezone to be applied to all entries by default.
|
|
13
|
+
attr_accessor timezone: String?
|
|
14
|
+
|
|
15
|
+
# Initialize the builder with the given Crontab instance.
|
|
16
|
+
#
|
|
17
|
+
# @rbs target: Zizq::Crontab
|
|
18
|
+
# @rbs timezone: String?
|
|
19
|
+
# @rbs paused: bool?
|
|
20
|
+
def initialize: (Zizq::Crontab target, ?timezone: String?, ?paused: bool?) -> untyped
|
|
21
|
+
|
|
22
|
+
# Add or replace an entry on the schedule
|
|
23
|
+
#
|
|
24
|
+
# If no entry with the given name exists, it is added to schedule. If an
|
|
25
|
+
# entry with the same name exist, this entry replaces that entry. If the
|
|
26
|
+
# entry is the same as the original, the result is idempotent.
|
|
27
|
+
#
|
|
28
|
+
# @rbs name: String
|
|
29
|
+
# @rbs expression: String
|
|
30
|
+
# @rbs timezone: String?
|
|
31
|
+
# @rbs paused: bool?
|
|
32
|
+
# @rbs return: Zizq::CrontabEntryBuilder
|
|
33
|
+
def define_entry: (String name, String expression, ?timezone: String?, ?paused: bool?) -> Zizq::CrontabEntryBuilder
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Generated from lib/zizq/crontab_entry.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
# Represents a single entry within a Crontab schedule.
|
|
5
|
+
#
|
|
6
|
+
# Each entry specifies the cron expression at which it executes,
|
|
7
|
+
# information about when it last/next enqueued a job, and details of the
|
|
8
|
+
# job that the entry enqueues.
|
|
9
|
+
#
|
|
10
|
+
# Entries can be paused or resumed, and can be deleted or redefined in place.
|
|
11
|
+
class CrontabEntry
|
|
12
|
+
# The Crontab schedule to which this entry belongs.
|
|
13
|
+
attr_reader crontab: Zizq::Crontab
|
|
14
|
+
|
|
15
|
+
# The name of this entry within the schedule.
|
|
16
|
+
attr_reader name: String
|
|
17
|
+
|
|
18
|
+
# The cron expression used to define the schedule for the entry.
|
|
19
|
+
#
|
|
20
|
+
# Both standard 5-field and enhanced 6-field cron (with seconds) are
|
|
21
|
+
# supported, along with @daily, @weekly etc.
|
|
22
|
+
attr_reader expression: String
|
|
23
|
+
|
|
24
|
+
# The timezone in which the schedule entry is processed.
|
|
25
|
+
#
|
|
26
|
+
# Defaults to the Zizq server timezone unless specified.
|
|
27
|
+
attr_reader timezone: String?
|
|
28
|
+
|
|
29
|
+
# Parameters that will be used to enqueue jobs each time the schedule fires.
|
|
30
|
+
#
|
|
31
|
+
# These are the same parameters as those used to enqueue jobs normally.
|
|
32
|
+
attr_reader job: EnqueueRequest
|
|
33
|
+
|
|
34
|
+
# True if this entry is currrently paused.
|
|
35
|
+
attr_reader paused: bool?
|
|
36
|
+
|
|
37
|
+
# The timestamp at which this entry was last paused.
|
|
38
|
+
attr_reader paused_at: Float?
|
|
39
|
+
|
|
40
|
+
# The timestamp at which this entry was last resumed.
|
|
41
|
+
attr_reader resumed_at: Float?
|
|
42
|
+
|
|
43
|
+
# The timestamp at which a job was last enqueued for this entry.
|
|
44
|
+
attr_reader last_enqueue_at: Float?
|
|
45
|
+
|
|
46
|
+
#
|
|
47
|
+
# The timestamp at which the next job will be enqueued for this entry.
|
|
48
|
+
attr_reader next_enqueue_at: Float?
|
|
49
|
+
|
|
50
|
+
# Initialize the entry with all configured parameters.
|
|
51
|
+
#
|
|
52
|
+
# @rbs crontab: Zizq::Crontab
|
|
53
|
+
# @rbs name: String
|
|
54
|
+
# @rbs expression: String
|
|
55
|
+
# @rbs timezone: String?
|
|
56
|
+
# @rbs job: EnqueueRequest
|
|
57
|
+
# @rbs paused: bool?
|
|
58
|
+
# @rbs paused_at: Float?
|
|
59
|
+
# @rbs resumed_at: Float?
|
|
60
|
+
# @rbs last_enqueue_at: Float?
|
|
61
|
+
# @rbs next_enqueue_at: Float?
|
|
62
|
+
def initialize: (Zizq::Crontab crontab, String name, String expression, job: EnqueueRequest, ?timezone: String?, ?paused: bool?, ?paused_at: Float?, ?resumed_at: Float?, ?last_enqueue_at: Float?, ?next_enqueue_at: Float?) -> untyped
|
|
63
|
+
|
|
64
|
+
# Replace this entry with another.
|
|
65
|
+
#
|
|
66
|
+
# This is equivalent to calling `crontab.define_entry` with the same name.
|
|
67
|
+
#
|
|
68
|
+
# @rbs expression: String
|
|
69
|
+
# @rbs timezone: String?
|
|
70
|
+
# @rbs paused: bool?
|
|
71
|
+
# @rbs return: Zizq::CrontabEntryBuilder
|
|
72
|
+
def redefine: (String expression, ?timezone: String?, ?paused: bool?) -> Zizq::CrontabEntryBuilder
|
|
73
|
+
|
|
74
|
+
# Delete the entry from the schedule.
|
|
75
|
+
def delete!: () -> untyped
|
|
76
|
+
|
|
77
|
+
# Pause the entry within the schedule.
|
|
78
|
+
#
|
|
79
|
+
# This is independent of the paused state of the Crontab itself.
|
|
80
|
+
def pause!: () -> untyped
|
|
81
|
+
|
|
82
|
+
# Resume this entry if it is currently paused.
|
|
83
|
+
#
|
|
84
|
+
# If the parent Crontab itself is paused, the entry will still not enqueue
|
|
85
|
+
# jobs until the Crontab is resumed.
|
|
86
|
+
def resume!: () -> untyped
|
|
87
|
+
|
|
88
|
+
# @private
|
|
89
|
+
# @rbs return: Zizq::cron_entry_params
|
|
90
|
+
def to_params: () -> Zizq::cron_entry_params
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
# @rbs result: Zizq::Resources::CronEntry
|
|
95
|
+
# @rbs return: self
|
|
96
|
+
def materialize_with: (Zizq::Resources::CronEntry result) -> self
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Generated from lib/zizq/crontab_entry_builder.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Zizq
|
|
4
|
+
# Builder class used to define individual entries within a Crontab schedule.
|
|
5
|
+
#
|
|
6
|
+
# This is used internally by `Zizq.define_crontab`. See documentation for
|
|
7
|
+
# that method for full details.
|
|
8
|
+
#
|
|
9
|
+
# Callers *must* call one of the enqueue methods to complete the build
|
|
10
|
+
# process.
|
|
11
|
+
class CrontabEntryBuilder
|
|
12
|
+
# The Crontab instance onto which entries are applied.
|
|
13
|
+
attr_reader target: Zizq::Crontab
|
|
14
|
+
|
|
15
|
+
# The name of the entry being built.
|
|
16
|
+
attr_reader name: String
|
|
17
|
+
|
|
18
|
+
# The cron expression for the entry.
|
|
19
|
+
attr_reader expression: String
|
|
20
|
+
|
|
21
|
+
# Optional timezone for the entry.
|
|
22
|
+
#
|
|
23
|
+
# Defaults to the Zizq server timezone when not specified.
|
|
24
|
+
attr_reader timezone: String?
|
|
25
|
+
|
|
26
|
+
# True if this entry will be paused.
|
|
27
|
+
attr_reader paused: bool?
|
|
28
|
+
|
|
29
|
+
# Callback through which the built entry is passed before being added to
|
|
30
|
+
# the Crontab schedule.
|
|
31
|
+
#
|
|
32
|
+
# The callback receives the Zizq::CrontabEntry instance and may return an
|
|
33
|
+
# alternative instance to be used after it has done any processing on the
|
|
34
|
+
# entry.
|
|
35
|
+
attr_reader callback: ^(Zizq::CrontabEntry) -> Zizq::CrontabEntry
|
|
36
|
+
|
|
37
|
+
# Initialize the builder with the given inputs.
|
|
38
|
+
#
|
|
39
|
+
# @rbs target: Zizq::Crontab
|
|
40
|
+
# @rbs name: String
|
|
41
|
+
# @rbs expression: String
|
|
42
|
+
# @rbs timezone: String?
|
|
43
|
+
# @rbs paused: bool?
|
|
44
|
+
# @rbs ?&block: (Zizq::CrontabEntry) -> Zizq::CrontabEntry
|
|
45
|
+
def initialize: (Zizq::Crontab target, String name, String expression, ?timezone: String?, ?paused: bool?) ?{ (?) -> untyped } -> untyped
|
|
46
|
+
|
|
47
|
+
# Enqueue a Zizq::Job or ActiveJob class using Zizq::ActiveJobConfig via
|
|
48
|
+
# this entry.
|
|
49
|
+
#
|
|
50
|
+
# @rbs job_class: Class & Zizq::JobConfig
|
|
51
|
+
# @rbs args: Array[untyped]
|
|
52
|
+
# @rbs kwargs: Hash[Symbol, untyped]
|
|
53
|
+
# @rbs &block: ?(EnqueueRequest) -> void
|
|
54
|
+
# @rbs return: void
|
|
55
|
+
def enqueue: (Class & Zizq::JobConfig job_class, *untyped args, **untyped kwargs) ?{ (EnqueueRequest) -> void } -> void
|
|
56
|
+
|
|
57
|
+
# Process a raw job enqueue for this entry.
|
|
58
|
+
#
|
|
59
|
+
# This is used for low-level or cross-language support.
|
|
60
|
+
#
|
|
61
|
+
# @rbs queue: String
|
|
62
|
+
# @rbs type: String
|
|
63
|
+
# @rbs payload: untyped
|
|
64
|
+
# @rbs priority: Integer?
|
|
65
|
+
# @rbs ready_at: Zizq::to_f?
|
|
66
|
+
# @rbs retry_limit: Integer?
|
|
67
|
+
# @rbs backoff: Zizq::backoff?
|
|
68
|
+
# @rbs retention: Zizq::retention?
|
|
69
|
+
# @rbs unique_key: String?
|
|
70
|
+
# @rbs unique_while: Zizq::unique_scope?
|
|
71
|
+
# @rbs return: void
|
|
72
|
+
def enqueue_raw: (queue: String, type: String, payload: untyped, **untyped opts) -> void
|
|
73
|
+
|
|
74
|
+
# Bulk enqueues are not supported via cron.
|
|
75
|
+
#
|
|
76
|
+
# @rbs &block: (BulkEnqueue) -> void
|
|
77
|
+
# @rbs return: self
|
|
78
|
+
def enqueue_bulk: () { (BulkEnqueue) -> void } -> self
|
|
79
|
+
|
|
80
|
+
# Provide common fields to be used when enqueueing a job.
|
|
81
|
+
#
|
|
82
|
+
# @rbs overrides: Hash[Symbol, untyped]
|
|
83
|
+
# @rbs return: EnqueueWith
|
|
84
|
+
def enqueue_with: (**untyped overrides) -> EnqueueWith
|
|
85
|
+
|
|
86
|
+
private
|
|
87
|
+
|
|
88
|
+
# @rbs job: EnqueueRequest
|
|
89
|
+
# @rbs return: untyped
|
|
90
|
+
def push_entry: (untyped req) -> untyped
|
|
91
|
+
end
|
|
92
|
+
end
|