Class: Journaled::Outbox::Event
- Inherits:
-
Object
- Object
- Journaled::Outbox::Event
- Defined in:
- app/models/journaled/outbox/event.rb
Overview
ActiveRecord model for Outbox-style event processing
This model is only used when the Outbox::Adapter is configured. Events are stored in the database and processed by worker daemons.
Successfully delivered events are deleted immediately. Failed events are marked with failed_at and can be queried or requeued.
Class Method Summary collapse
-
.fetch_batch_for_update ⇒ Array<Journaled::Outbox::Event>
Fetch a batch of events for processing using SELECT FOR UPDATE.
-
.oldest_non_failed_timestamp ⇒ Time?
Get the oldest non-failed event’s timestamp.
Instance Method Summary collapse
-
#requeue! ⇒ Boolean
Requeue a failed event for processing.
Class Method Details
.fetch_batch_for_update ⇒ Array<Journaled::Outbox::Event>
Fetch a batch of events for processing using SELECT FOR UPDATE
33 34 35 36 37 38 |
# File 'app/models/journaled/outbox/event.rb', line 33 def self.fetch_batch_for_update ready_to_process .limit(Journaled.worker_batch_size) .lock .to_a end |
.oldest_non_failed_timestamp ⇒ Time?
Get the oldest non-failed event’s timestamp
55 56 57 |
# File 'app/models/journaled/outbox/event.rb', line 55 def self. ready_to_process.order(:id).limit(1).pick(:created_at) end |
Instance Method Details
#requeue! ⇒ Boolean
Requeue a failed event for processing
Clears failure information so the event can be retried.
45 46 47 48 49 50 |
# File 'app/models/journaled/outbox/event.rb', line 45 def requeue! update!( failed_at: nil, failure_reason: nil, ) end |