Sha256: 7d607b55c0f90215d5a542078e23586c9bfd57dbd99cf81914e0c06454496f10
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module DirtyPipeline class Transaction attr_reader :locker, :storage, :subject, :pipeline, :event def initialize(pipeline, event) @pipeline = pipeline @subject = pipeline.subject @storage = pipeline.storage @event = event end 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 def with_abort_handling return unless catch(:abort_transaction) { yield; nil } event.abort! unless event.abort? raise ActiveRecord::Rollback end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dirty_pipeline-0.9.0 | lib/dirty_pipeline/transaction.rb |