Class: Zizq::CrontabEntryBuilder
- Inherits:
-
Object
- Object
- Zizq::CrontabEntryBuilder
- Defined in:
- lib/zizq/crontab_entry_builder.rb
Overview
Builder class used to define individual entries within a Crontab schedule.
This is used internally by ‘Zizq.define_crontab`. See documentation for that method for full details.
Callers must call one of the enqueue methods to complete the build process.
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Callback through which the built entry is passed before being added to the Crontab schedule.
-
#expression ⇒ Object
readonly
The cron expression for the entry.
-
#name ⇒ Object
readonly
The name of the entry being built.
-
#paused ⇒ Object
readonly
True if this entry will be paused.
-
#target ⇒ Object
readonly
The Crontab instance onto which entries are applied.
-
#timezone ⇒ Object
readonly
Optional timezone for the entry.
Instance Method Summary collapse
-
#enqueue(job_class, *args, **kwargs, &block) ⇒ Object
Enqueue a Zizq::Job or ActiveJob class using Zizq::ActiveJobConfig via this entry.
-
#enqueue_bulk(&block) ⇒ Object
Bulk enqueues are not supported via cron.
-
#enqueue_raw(queue:, type:, payload:, **opts) ⇒ Object
Process a raw job enqueue for this entry.
-
#enqueue_with(**overrides) ⇒ Object
Provide common fields to be used when enqueueing a job.
-
#initialize(target, name, expression, timezone: nil, paused: nil, &block) ⇒ CrontabEntryBuilder
constructor
Initialize the builder with the given inputs.
Constructor Details
#initialize(target, name, expression, timezone: nil, paused: nil, &block) ⇒ CrontabEntryBuilder
Initialize the builder with the given inputs.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/zizq/crontab_entry_builder.rb', line 49 def initialize(target, name, expression, timezone: nil, paused: nil, &block) @target = target @name = name @expression = expression @timezone = timezone @paused = paused @callback = block || :itself.to_proc end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Callback through which the built entry is passed before being added to the Crontab schedule.
The callback receives the Zizq::CrontabEntry instance and may return an alternative instance to be used after it has done any processing on the entry.
39 40 41 |
# File 'lib/zizq/crontab_entry_builder.rb', line 39 def callback @callback end |
#expression ⇒ Object (readonly)
The cron expression for the entry.
23 24 25 |
# File 'lib/zizq/crontab_entry_builder.rb', line 23 def expression @expression end |
#name ⇒ Object (readonly)
The name of the entry being built.
20 21 22 |
# File 'lib/zizq/crontab_entry_builder.rb', line 20 def name @name end |
#paused ⇒ Object (readonly)
True if this entry will be paused.
31 32 33 |
# File 'lib/zizq/crontab_entry_builder.rb', line 31 def paused @paused end |
#target ⇒ Object (readonly)
The Crontab instance onto which entries are applied.
17 18 19 |
# File 'lib/zizq/crontab_entry_builder.rb', line 17 def target @target end |
#timezone ⇒ Object (readonly)
Optional timezone for the entry.
Defaults to the Zizq server timezone when not specified.
28 29 30 |
# File 'lib/zizq/crontab_entry_builder.rb', line 28 def timezone @timezone end |
Instance Method Details
#enqueue(job_class, *args, **kwargs, &block) ⇒ Object
Enqueue a Zizq::Job or ActiveJob class using Zizq::ActiveJobConfig via this entry.
71 72 73 |
# File 'lib/zizq/crontab_entry_builder.rb', line 71 def enqueue(job_class, *args, **kwargs, &block) push_entry(Zizq.build_enqueue_request(job_class, *args, **kwargs, &block)) end |
#enqueue_bulk(&block) ⇒ Object
Bulk enqueues are not supported via cron.
98 99 100 |
# File 'lib/zizq/crontab_entry_builder.rb', line 98 def enqueue_bulk(&block) raise NotImplementedError, 'bulk enqueues are not supported via cron' end |
#enqueue_raw(queue:, type:, payload:, **opts) ⇒ Object
Process a raw job enqueue for this entry.
This is used for low-level or cross-language support.
90 91 92 |
# File 'lib/zizq/crontab_entry_builder.rb', line 90 def enqueue_raw(queue:, type:, payload:, **opts) push_entry(EnqueueRequest.new(queue:, type:, payload:, **opts)) end |
#enqueue_with(**overrides) ⇒ Object
Provide common fields to be used when enqueueing a job.
106 107 108 |
# File 'lib/zizq/crontab_entry_builder.rb', line 106 def enqueue_with(**overrides) EnqueueWith.new(self, overrides) end |