Module: Aggro::Saga
Overview
Public: Mixin to turn a PORO into an Aggro saga.
Instance Method Summary
collapse
Methods included from EventDSL
#handles_event?
Methods included from BindingDSL
#bind
#attributes, #initialize, #serialized_attributes
Instance Method Details
#bindings ⇒ Object
15
16
17
|
# File 'lib/aggro/saga.rb', line 15
def bindings
@runner.bindings
end
|
#default_filters ⇒ Object
19
20
21
|
# File 'lib/aggro/saga.rb', line 19
def default_filters
{ correlation_id: correlation_id }
end
|
#saga_id ⇒ Object
23
24
25
|
# File 'lib/aggro/saga.rb', line 23
def saga_id
@saga_id ||= SecureRandom.uuid
end
|
#start ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/aggro/saga.rb', line 27
def start
fail 'Saga is not valid' unless valid?
promise = SagaStatus.new(saga_id)
message = Message::StartSaga.new Aggro.local_node.id, saga_id, to_details
response = primary_node.client.post message
if response.is_a? Message::OK
promise
else
fail 'Saga could not be started'
end
end
|