Class: Amazon::Coral::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/amazon/coral/dispatcher.rb

Overview

Dispatches requests to a particular remote service operation.

Instance Method Summary collapse

Constructor Details

#initialize(orchestrator, service_name, operation_name) ⇒ Dispatcher

Instantiates a Dispatcher with the specified Orchestrator and strings declaring the service and operation to which requests will be directed.



13
14
15
16
17
# File 'lib/amazon/coral/dispatcher.rb', line 13

def initialize(orchestrator, service_name, operation_name)
  @orchestrator = orchestrator
  @service_name = service_name
  @operation_name = operation_name
end

Instance Method Details

#dispatch(call, input) ⇒ Object

Invoke the remote service and produce a result for the provided Call object and input hash.



21
22
23
24
25
26
27
28
29
# File 'lib/amazon/coral/dispatcher.rb', line 21

def dispatch(call, input)
  request = {
    :operation_name => @operation_name, :service_name => @service_name, 
    :identity => call.identity, :id => call.request_id, :value => input
  }
  reply = @orchestrator.orchestrate(request)

  return reply[:value]
end