class Gruf::Response
Wraps the active call operation to provide metadata and timing around the request
Attributes
@return [Boolean] Whether or not the operation was cancelled
@return [Time] The set deadline on the call
@return [Float] The time that the request took to execute
@return [Hash] The metadata that was attached to the operation
@return [GRPC::ActiveCall::Operation] The operation that was executed for the given request
@return [Hash] The trailing metadata that the service returned
Public Class Methods
Initialize a response object with the given gRPC operation
@param [GRPC::ActiveCall::Operation] operation The given operation for the current call @param [StdClass] message @param [Float] execution_time
The amount of time that the response took to occur
# File lib/gruf/response.rb, line 43 def initialize(operation:, message:, execution_time: nil) @operation = operation @message = message @metadata = operation.metadata @trailing_metadata = operation.trailing_metadata @deadline = operation.deadline @cancelled = operation.cancelled? @execution_time = execution_time || 0.0 end
Public Instance Methods
Return execution time of the call internally on the server in ms
@return [Float] The execution time of the response
# File lib/gruf/response.rb, line 67 def internal_execution_time trailing_metadata['timer'].to_f end
Return the message returned by the request
@return [Object] The protobuf response message
# File lib/gruf/response.rb, line 58 def message @message ||= @operation.execute end