Sha256: 9da0c0d5e7e1ec97a374a6ddba8d6047609745574aad93560b391449a3bde59e
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 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 subject.transaction 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dirty_pipeline-0.8.3 | lib/dirty_pipeline/transaction.rb |
dirty_pipeline-0.8.2 | lib/dirty_pipeline/transaction.rb |
dirty_pipeline-0.8.1 | lib/dirty_pipeline/transaction.rb |