Class: Amazon::Coral::Call

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

Instance Method Summary collapse

Constructor Details

#initialize(dispatcher) ⇒ Call

Create a new Call object tied to a specific Dispatcher.



12
13
14
15
16
# File 'lib/amazon/coral/call.rb', line 12

def initialize(dispatcher)
  @dispatcher = dispatcher
  @identity = {}
  @request_id = nil
end

Instance Method Details

#call(input = {}) ⇒ Object

Invoke the remote service and return the result.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/amazon/coral/call.rb', line 41

def call(input = {})
  begin
    @request_id = UUIDTools::UUID.random_create if @request_id.nil?

    return @dispatcher.dispatch(self, input)
  rescue Timeout::Error => timeout
    return {
      "Error" => {
        "Type" => "Receiver",
        "Code" => "Timeout",
        "Details" => timeout
      }
    }
  rescue Exception => e
    return {
      "Error" => {
        "Type" => "Sender",
        "Code" => "InternalFailure",
        "Details" => e
      }
    }
  end
end

#identityObject

Retrieve the hash of identity information for the outgoing request. The returned hash is mutable such that callers may add or remove identity information from it.



26
27
28
# File 'lib/amazon/coral/call.rb', line 26

def identity
  @identity
end

#identity=(i) ⇒ Object

Specify a hash containing identity information for the outgoing request. This is protocol specific but typically contains account names, certificates or other credentials.



20
21
22
# File 'lib/amazon/coral/call.rb', line 20

def identity=(i)
  @identity = i.to_hash
end

#request_idObject

Retrieve the request ID returned by the remote service.



36
37
38
# File 'lib/amazon/coral/call.rb', line 36

def request_id
  @request_id
end

#request_id=(r) ⇒ Object

Specify the request ID to attach to the outgoing request. (Internal only)



31
32
33
# File 'lib/amazon/coral/call.rb', line 31

def request_id=(r)
  @request_id = r
end