Class: DirtyPipeline::Transaction
- Inherits:
-
Object
- Object
- DirtyPipeline::Transaction
- Defined in:
- lib/dirty_pipeline/transaction.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#locker ⇒ Object
readonly
Returns the value of attribute locker.
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(pipeline, event) ⇒ Transaction
constructor
A new instance of Transaction.
Constructor Details
#initialize(pipeline, event) ⇒ Transaction
Returns a new instance of Transaction.
4 5 6 7 8 9 |
# File 'lib/dirty_pipeline/transaction.rb', line 4 def initialize(pipeline, event) @pipeline = pipeline @subject = pipeline.subject @storage = pipeline.storage @event = event end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
3 4 5 |
# File 'lib/dirty_pipeline/transaction.rb', line 3 def event @event end |
#locker ⇒ Object (readonly)
Returns the value of attribute locker.
3 4 5 |
# File 'lib/dirty_pipeline/transaction.rb', line 3 def locker @locker end |
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
3 4 5 |
# File 'lib/dirty_pipeline/transaction.rb', line 3 def pipeline @pipeline end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
3 4 5 |
# File 'lib/dirty_pipeline/transaction.rb', line 3 def storage @storage end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
3 4 5 |
# File 'lib/dirty_pipeline/transaction.rb', line 3 def subject @subject end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dirty_pipeline/transaction.rb', line 11 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 |