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(operation:, message:, 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(operation:, message:, execution_time: nil) ⇒ Response
Initialize a response object with the given gRPC operation
49 50 51 52 53 54 55 56 57 |
# File 'lib/gruf/response.rb', line 49 def initialize(operation:, message:, execution_time: nil) @operation = operation @message = @metadata = operation. @trailing_metadata = operation. @deadline = operation.deadline @cancelled = operation.cancelled? @execution_time = execution_time || 0.0 end |
Instance Attribute Details
#cancelled ⇒ Object (readonly)
Returns the value of attribute cancelled.
37 38 39 |
# File 'lib/gruf/response.rb', line 37 def cancelled @cancelled end |
#deadline ⇒ Object (readonly)
Returns the value of attribute deadline.
34 35 36 |
# File 'lib/gruf/response.rb', line 34 def deadline @deadline end |
#execution_time ⇒ Object (readonly)
Returns the value of attribute execution_time.
40 41 42 |
# File 'lib/gruf/response.rb', line 40 def execution_time @execution_time end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
28 29 30 |
# File 'lib/gruf/response.rb', line 28 def @metadata end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
25 26 27 |
# File 'lib/gruf/response.rb', line 25 def operation @operation end |
#trailing_metadata ⇒ Object (readonly)
Returns the value of attribute trailing_metadata.
31 32 33 |
# File 'lib/gruf/response.rb', line 31 def @trailing_metadata end |
Instance Method Details
#internal_execution_time ⇒ Float
Return execution time of the call internally on the server in ms
73 74 75 |
# File 'lib/gruf/response.rb', line 73 def internal_execution_time ['timer'].to_f end |
#message ⇒ Object
Return the message returned by the request
64 65 66 |
# File 'lib/gruf/response.rb', line 64 def @message ||= @operation.execute end |