Class: KubeMQ::CQ::QueryResponse
- Inherits:
-
Object
- Object
- KubeMQ::CQ::QueryResponse
- Defined in:
- lib/kubemq/cq/query_response.rb
Overview
Response returned by KubeMQ::CQClient#send_query after a subscriber processes the query.
Contains the response #body and #metadata, plus a #cache_hit flag indicating whether the response was served from the broker's server-side cache.
Instance Attribute Summary collapse
-
#body ⇒ String?
readonly
Response payload.
-
#cache_hit ⇒ Object
readonly
Returns the value of attribute cache_hit.
-
#client_id ⇒ String
readonly
The responder's client identifier.
-
#error ⇒ String?
readonly
Error description if execution failed.
-
#executed ⇒ Boolean
readonly
trueif the query was executed successfully. -
#metadata ⇒ String?
readonly
Response metadata.
-
#request_id ⇒ String
readonly
The original query request identifier.
-
#tags ⇒ Hash{String => String}
readonly
User-defined key-value tags.
-
#timestamp ⇒ Integer
readonly
Broker-assigned response timestamp (Unix nanoseconds).
Instance Method Summary collapse
-
#initialize(client_id:, request_id:, executed:, error: nil, timestamp: 0, tags: nil, body: nil, metadata: nil, cache_hit: false) ⇒ QueryResponse
constructor
A new instance of QueryResponse.
Constructor Details
#initialize(client_id:, request_id:, executed:, error: nil, timestamp: 0, tags: nil, body: nil, metadata: nil, cache_hit: false) ⇒ QueryResponse
Returns a new instance of QueryResponse.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/kubemq/cq/query_response.rb', line 45 def initialize(client_id:, request_id:, executed:, error: nil, timestamp: 0, tags: nil, body: nil, metadata: nil, cache_hit: false) @client_id = client_id @request_id = request_id @executed = executed @error = error @timestamp = @tags = || {} @body = body @metadata = @cache_hit = cache_hit end |
Instance Attribute Details
#body ⇒ String? (readonly)
Returns response payload.
33 34 |
# File 'lib/kubemq/cq/query_response.rb', line 33 attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags, :body, :metadata, :cache_hit |
#cache_hit ⇒ Object (readonly)
Returns the value of attribute cache_hit.
33 34 |
# File 'lib/kubemq/cq/query_response.rb', line 33 attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags, :body, :metadata, :cache_hit |
#client_id ⇒ String (readonly)
Returns the responder's client identifier.
33 34 35 |
# File 'lib/kubemq/cq/query_response.rb', line 33 def client_id @client_id end |
#error ⇒ String? (readonly)
Returns error description if execution failed.
33 34 |
# File 'lib/kubemq/cq/query_response.rb', line 33 attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags, :body, :metadata, :cache_hit |
#executed ⇒ Boolean (readonly)
Returns true if the query was executed successfully.
33 34 |
# File 'lib/kubemq/cq/query_response.rb', line 33 attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags, :body, :metadata, :cache_hit |
#metadata ⇒ String? (readonly)
Returns response metadata.
33 34 |
# File 'lib/kubemq/cq/query_response.rb', line 33 attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags, :body, :metadata, :cache_hit |
#request_id ⇒ String (readonly)
Returns the original query request identifier.
33 34 |
# File 'lib/kubemq/cq/query_response.rb', line 33 attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags, :body, :metadata, :cache_hit |
#tags ⇒ Hash{String => String} (readonly)
Returns user-defined key-value tags.
33 34 |
# File 'lib/kubemq/cq/query_response.rb', line 33 attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags, :body, :metadata, :cache_hit |
#timestamp ⇒ Integer (readonly)
Returns broker-assigned response timestamp (Unix nanoseconds).
33 34 |
# File 'lib/kubemq/cq/query_response.rb', line 33 attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags, :body, :metadata, :cache_hit |