class Aggro::Handler::StartSaga
Private: Handler
for incoming command requests.
Public Instance Methods
call()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 5 def call locator.local? ? handle_local : handle_foreign end
Private Instance Methods
create_channel()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 11 def create_channel channel = Channel.new message.id, 'Aggro::SagaRunner' Aggro.channels[message.id] = channel end
create_saga()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 17 def create_saga Aggro.store.create message.id, 'Aggro::SagaRunner' end
handle_foreign()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 25 def handle_foreign locator.primary_node.client.post message end
handle_known()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 29 def handle_known create_saga create_channel Aggro.channels[message.id].forward_command start_command Message::OK.new end
handle_local()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 38 def handle_local saga_known? ? handle_known : handle_unknown end
handle_unknown()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 42 def handle_unknown Message::UnknownOperation.new end
locator()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 21 def locator @locator ||= Locator.new(message.id) end
saga_known?()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 46 def saga_known? ActiveSupport::Inflector.safe_constantize message.name end
start_command()
click to toggle source
# File lib/aggro/handler/start_saga.rb, line 50 def start_command SagaRunner::StartSaga.new name: message.name, details: message.args, id: message.id end