lib/dirty_pipeline/transaction.rb in dirty_pipeline-0.6.0 vs lib/dirty_pipeline/transaction.rb in dirty_pipeline-0.6.1
- old
+ new
@@ -7,30 +7,19 @@
@storage = pipeline.storage
@event = event
end
def call
- event.start!
- with_transaction { |*targs| yield(*targs) }
- end
-
- def retry
- event.attempt_retry!
- with_transaction { |*targs| yield(*targs) }
- end
-
- private
-
- def with_transaction
pipeline.schedule_cleanup
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)
@@ -40,9 +29,11 @@
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