Sha256: 331efe5f83c2de2e19da455aba0ce43054c47d5fe85ef30d4e4fa7406acca8cf
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 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 destination, action, max_attempts_count = pipeline.find_transition(event.transition) .values_at(:to, :action, :attempts) storage.commit!(event) # FIXME: make configurable, now - hardcoded to AR API subject.transaction(requires_new: true) do with_abort_handling { yield(destination, 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dirty_pipeline-0.7.1 | lib/dirty_pipeline/transaction.rb |
dirty_pipeline-0.7.0 | lib/dirty_pipeline/transaction.rb |