Module: Aggro::Saga

Extended by:
ActiveSupport::Concern
Includes:
AttributeDSL, BindingDSL, EventDSL
Defined in:
lib/aggro/saga.rb

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

Methods included from AttributeDSL

#attributes, #initialize, #serialized_attributes

Instance Method Details

#bindingsObject



15
16
17
# File 'lib/aggro/saga.rb', line 15

def bindings
  @runner.bindings
end

#default_filtersObject



19
20
21
# File 'lib/aggro/saga.rb', line 19

def default_filters
  { correlation_id: correlation_id }
end

#saga_idObject



23
24
25
# File 'lib/aggro/saga.rb', line 23

def saga_id
  @saga_id ||= SecureRandom.uuid
end

#startObject



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