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 ⇒ Boolean
readonly
Whether or not the operation was cancelled.
-
#deadline ⇒ Time
readonly
The set deadline on the call.
-
#execution_time ⇒ Float
readonly
The time that the request took to execute.
-
#metadata ⇒ Hash
readonly
The metadata that was attached to the operation.
-
#operation ⇒ GRPC::ActiveCall::Operation
readonly
The operation that was executed for the given request.
-
#trailing_metadata ⇒ Hash
readonly
The trailing metadata that the service returned.
Instance Method Summary collapse
-
#initialize(op, execution_time = nil) ⇒ Response
constructor
Initialize a response object with the given gRPC operation.
-
#internal_execution_time ⇒ Float
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
Initialize a response object with the given gRPC operation
40 41 42 43 44 45 46 47 48 |
# File 'lib/gruf/response.rb', line 40 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 ⇒ Boolean (readonly)
Returns Whether or not the operation was cancelled.
30 31 32 |
# File 'lib/gruf/response.rb', line 30 def cancelled @cancelled end |
#deadline ⇒ Time (readonly)
Returns The set deadline on the call.
28 29 30 |
# File 'lib/gruf/response.rb', line 28 def deadline @deadline end |
#execution_time ⇒ Float (readonly)
Returns The time that the request took to execute.
32 33 34 |
# File 'lib/gruf/response.rb', line 32 def execution_time @execution_time end |
#metadata ⇒ Hash (readonly)
Returns The metadata that was attached to the operation.
24 25 26 |
# File 'lib/gruf/response.rb', line 24 def @metadata end |
#operation ⇒ GRPC::ActiveCall::Operation (readonly)
Returns The operation that was executed for the given request.
22 23 24 |
# File 'lib/gruf/response.rb', line 22 def operation @operation end |
#trailing_metadata ⇒ Hash (readonly)
Returns The trailing metadata that the service returned.
26 27 28 |
# File 'lib/gruf/response.rb', line 26 def @trailing_metadata end |
Instance Method Details
#internal_execution_time ⇒ Float
Return execution time of the call internally on the server in ms
64 65 66 |
# File 'lib/gruf/response.rb', line 64 def internal_execution_time ['timer'].to_f end |
#message ⇒ Object
Return the message returned by the request
55 56 57 |
# File 'lib/gruf/response.rb', line 55 def @message ||= op.execute end |