Class: TransactionalOutbox::Database::Adapters::Sequel
- Defined in:
- lib/transactional_outbox/database/adapters/sequel.rb
Instance Method Summary collapse
- #delete_events(ids) ⇒ Object
- #fetch_events(queue, batch_size) ⇒ Object
- #fetch_queues ⇒ Object
- #insert_events(attributes) ⇒ Object
- #move_to_processing(ids) ⇒ Object
- #transaction(*options) ⇒ Object
Methods included from InstanceMethods
Instance Method Details
#delete_events(ids) ⇒ Object
11 |
# File 'lib/transactional_outbox/database/adapters/sequel.rb', line 11 def delete_events(ids) = table_object.where(id: ids).delete |
#fetch_events(queue, batch_size) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/transactional_outbox/database/adapters/sequel.rb', line 19 def fetch_events(queue, batch_size) dataset = claimable_scope(table_object.where(queue:)).order(:created_at).limit(batch_size) dataset = dataset.for_update.skip_locked unless config.test_environment dataset.all end |
#fetch_queues ⇒ Object
9 |
# File 'lib/transactional_outbox/database/adapters/sequel.rb', line 9 def fetch_queues = claimable_scope(table_object).select(:queue).distinct.map { |event| event[:queue] } |
#insert_events(attributes) ⇒ Object
8 |
# File 'lib/transactional_outbox/database/adapters/sequel.rb', line 8 def insert_events(attributes) = table_object.multi_insert(attributes) |
#move_to_processing(ids) ⇒ Object
13 14 15 16 17 |
# File 'lib/transactional_outbox/database/adapters/sequel.rb', line 13 def move_to_processing(ids) table_object .where(id: ids) .update(status: TransactionalOutbox::EVENT_PROCESSING_STATUS, processing_started_at: current_time) end |
#transaction(*options) ⇒ Object
7 |
# File 'lib/transactional_outbox/database/adapters/sequel.rb', line 7 def transaction(*, &) = db.transaction(*, &) |