Class: Gruf::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/gruf/response.rb

Overview

Wraps the active call operation to provide metadata and timing around the request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation:, message:, execution_time: nil) ⇒ Response

Initialize a response object with the given gRPC operation



43
44
45
46
47
48
49
50
51
# File 'lib/gruf/response.rb', line 43

def initialize(operation:, message:, execution_time: nil)
  @operation = operation
  @message = message
   = operation.
   = operation.
  @deadline = operation.deadline
  @cancelled = operation.cancelled?
  @execution_time = execution_time || 0.0
end

Instance Attribute Details

#cancelledBoolean (readonly)



32
33
34
# File 'lib/gruf/response.rb', line 32

def cancelled
  @cancelled
end

#deadlineTime (readonly)



30
31
32
# File 'lib/gruf/response.rb', line 30

def deadline
  @deadline
end

#execution_timeFloat (readonly)



34
35
36
# File 'lib/gruf/response.rb', line 34

def execution_time
  @execution_time
end

#metadataHash (readonly)



26
27
28
# File 'lib/gruf/response.rb', line 26

def 
  
end

#operationGRPC::ActiveCall::Operation (readonly)



24
25
26
# File 'lib/gruf/response.rb', line 24

def operation
  @operation
end

#trailing_metadataHash (readonly)



28
29
30
# File 'lib/gruf/response.rb', line 28

def 
  
end

Instance Method Details

#internal_execution_timeFloat

Return execution time of the call internally on the server in ms



67
68
69
# File 'lib/gruf/response.rb', line 67

def internal_execution_time
  ['timer'].to_f
end

#messageObject

Return the message returned by the request



58
59
60
# File 'lib/gruf/response.rb', line 58

def message
  @message ||= @operation.execute
end