Class: Gruf::Response
- Inherits:
-
Object
- Object
- Gruf::Response
- Defined in:
- lib/gruf/response.rb
Overview
Wraps the active call operation to provide metadata and timing around the request
Instance Attribute Summary collapse
-
#cancelled ⇒ Object
readonly
Returns the value of attribute cancelled.
-
#deadline ⇒ Object
readonly
Returns the value of attribute deadline.
-
#execution_time ⇒ Object
readonly
Returns the value of attribute execution_time.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#trailing_metadata ⇒ Object
readonly
Returns the value of attribute trailing_metadata.
Instance Method Summary collapse
-
#initialize(op, execution_time = nil) ⇒ Response
constructor
A new instance of Response.
-
#internal_execution_time ⇒ Integer
Return execution time of the call internally on the server in ms.
-
#message ⇒ Object
Return the message returned by the request.
Constructor Details
#initialize(op, execution_time = nil) ⇒ Response
Returns a new instance of Response.
28 29 30 31 32 33 34 35 36 |
# File 'lib/gruf/response.rb', line 28 def initialize(op, execution_time = nil) @operation = op @message = op.execute @metadata = op. @trailing_metadata = op. @deadline = op.deadline @cancelled = op.cancelled? @execution_time = execution_time || 0.0 end |
Instance Attribute Details
#cancelled ⇒ Object (readonly)
Returns the value of attribute cancelled.
22 23 24 |
# File 'lib/gruf/response.rb', line 22 def cancelled @cancelled end |
#deadline ⇒ Object (readonly)
Returns the value of attribute deadline.
22 23 24 |
# File 'lib/gruf/response.rb', line 22 def deadline @deadline end |
#execution_time ⇒ Object (readonly)
Returns the value of attribute execution_time.
22 23 24 |
# File 'lib/gruf/response.rb', line 22 def execution_time @execution_time end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
22 23 24 |
# File 'lib/gruf/response.rb', line 22 def @metadata end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
22 23 24 |
# File 'lib/gruf/response.rb', line 22 def operation @operation end |
#trailing_metadata ⇒ Object (readonly)
Returns the value of attribute trailing_metadata.
22 23 24 |
# File 'lib/gruf/response.rb', line 22 def @trailing_metadata end |
Instance Method Details
#internal_execution_time ⇒ Integer
Return execution time of the call internally on the server in ms
50 51 52 53 |
# File 'lib/gruf/response.rb', line 50 def internal_execution_time key = Gruf..fetch(:output_metadata_timer, {}).fetch(:metadata_key, 'timer') [key].to_f end |
#message ⇒ Object
Return the message returned by the request
41 42 43 |
# File 'lib/gruf/response.rb', line 41 def @message ||= op.execute end |