Class: SidekiqBatch::Announcement
- Inherits:
-
Object
- Object
- SidekiqBatch::Announcement
- Defined in:
- app/models/sidekiq_batch/announcement.rb
Defined Under Namespace
Classes: Fired
Constant Summary collapse
- CLAIM_SQL =
-> 'key' IS NULL, not the jsonb?operator: sanitize_sql_array counts every?in the statement as a bind placeholder, so a jsonb?would raisewrong number of bind variableson the way to the database. <<~SQL.squish UPDATE sidekiq_batches SET callbacks_fired = callbacks_fired || jsonb_build_object(?, to_jsonb(NOW())), updated_at = NOW() WHERE id = ? AND callbacks_fired -> ? IS NULL SQL
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Array<Fired>
One entry per callback actually enqueued.
-
#initialize(batch) ⇒ Announcement
constructor
A new instance of Announcement.
Constructor Details
#initialize(batch) ⇒ Announcement
Returns a new instance of Announcement.
21 22 23 |
# File 'app/models/sidekiq_batch/announcement.rb', line 21 def initialize(batch) @batch = batch end |
Class Method Details
.call(batch) ⇒ Object
17 18 19 |
# File 'app/models/sidekiq_batch/announcement.rb', line 17 def self.call(batch) new(batch).call end |
Instance Method Details
#call ⇒ Array<Fired>
Returns one entry per callback actually enqueued.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/sidekiq_batch/announcement.rb', line 26 def call # An unfinished batch has no outcome to announce, and claiming here would # spend the announcement before there is anything to announce. return [] unless @batch.terminal? fired = events.filter_map { |event| fire(event) } resolve! @batch.reload fired end |