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(op, execution_time = nil) ⇒ Response

Initialize a response object with the given gRPC operation



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

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

Instance Attribute Details

#cancelledBoolean (readonly)



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

def cancelled
  @cancelled
end

#deadlineTime (readonly)



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

def deadline
  @deadline
end

#execution_timeFloat (readonly)



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

def execution_time
  @execution_time
end

#metadataHash (readonly)



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

def 
  
end

#operationGRPC::ActiveCall::Operation (readonly)



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

def operation
  @operation
end

#trailing_metadataHash (readonly)



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

def 
  
end

Instance Method Details

#internal_execution_timeFloat

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



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

def internal_execution_time
  key = Gruf.instrumentation_options.fetch(:output_metadata_timer, {}).fetch(:metadata_key, 'timer')
  [key].to_f
end

#messageObject

Return the message returned by the request



56
57
58
# File 'lib/gruf/response.rb', line 56

def message
  @message ||= op.execute
end