class DirtyPipeline::Transaction
Attributes
event[R]
locker[R]
pipeline[R]
storage[R]
subject[R]
Public Class Methods
new(pipeline, event)
click to toggle source
# File lib/dirty_pipeline/transaction.rb, line 4 def initialize(pipeline, event) @pipeline = pipeline @subject = pipeline.subject @storage = pipeline.storage @event = event end
Public Instance Methods
call() { |action, *args| ... }
click to toggle source
# File lib/dirty_pipeline/transaction.rb, line 11 def call pipeline.schedule_cleanup # Split attempts config and event dispatching action, max_attempts_count = pipeline.find_transition!(event).values_at(:action, :attempts) storage.commit!(event) # FIXME: make configurable, now - hardcoded to AR API # subject.transaction(requires_new: true) do subject.transaction do with_abort_handling { yield(action, *event.args) } end rescue => exception event.link_exception(exception) if max_attempts_count.to_i > event.attempts_count event.retry! pipeline.schedule_retry end raise ensure storage.commit!(event) end
Private Instance Methods
with_abort_handling() { || ... }
click to toggle source
# File lib/dirty_pipeline/transaction.rb, line 38 def with_abort_handling return unless catch(:abort_transaction) { yield; nil } event.abort! unless event.abort? raise ActiveRecord::Rollback end