Class: KubeMQ::CQ::QueryMessage
- Inherits:
-
Object
- Object
- KubeMQ::CQ::QueryMessage
- Defined in:
- lib/kubemq/cq/query_message.rb
Overview
Outbound query message for the request/reply (with data) pattern.
Construct a QueryMessage and pass it to KubeMQ::CQClient#send_query.
The broker forwards the query to a subscriber and returns a
QueryResponse containing the response data. Optionally set
#cache_key and #cache_ttl for server-side response caching.
Instance Attribute Summary collapse
-
#body ⇒ String?
Message payload (binary-safe).
-
#cache_key ⇒ String?
Cache key for server-side response caching.
-
#cache_ttl ⇒ Integer?
Cache TTL in seconds.
-
#channel ⇒ String
Target channel name.
-
#id ⇒ String
Unique message identifier (auto-generated UUID if not provided).
-
#metadata ⇒ String?
Arbitrary metadata string.
-
#tags ⇒ Hash{String => String}
User-defined key-value tags.
-
#timeout ⇒ Integer
Maximum time to wait for a response.
Instance Method Summary collapse
-
#initialize(channel:, timeout:, metadata: nil, body: nil, tags: nil, id: nil, cache_key: nil, cache_ttl: nil) ⇒ QueryMessage
constructor
A new instance of QueryMessage.
Constructor Details
#initialize(channel:, timeout:, metadata: nil, body: nil, tags: nil, id: nil, cache_key: nil, cache_ttl: nil) ⇒ QueryMessage
timeout is in milliseconds
Returns a new instance of QueryMessage.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/kubemq/cq/query_message.rb', line 57 def initialize(channel:, timeout:, metadata: nil, body: nil, tags: nil, id: nil, cache_key: nil, cache_ttl: nil) @id = id || SecureRandom.uuid @channel = channel @timeout = timeout = @body = body = || {} @cache_key = cache_key @cache_ttl = cache_ttl end |
Instance Attribute Details
#body ⇒ String?
Returns message payload (binary-safe).
46 |
# File 'lib/kubemq/cq/query_message.rb', line 46 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout, :cache_key, :cache_ttl |
#cache_key ⇒ String?
Returns cache key for server-side response caching.
46 |
# File 'lib/kubemq/cq/query_message.rb', line 46 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout, :cache_key, :cache_ttl |
#cache_ttl ⇒ Integer?
Returns cache TTL in seconds.
46 |
# File 'lib/kubemq/cq/query_message.rb', line 46 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout, :cache_key, :cache_ttl |
#channel ⇒ String
Returns target channel name.
46 |
# File 'lib/kubemq/cq/query_message.rb', line 46 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout, :cache_key, :cache_ttl |
#id ⇒ String
Returns unique message identifier (auto-generated UUID if not provided).
46 47 48 |
# File 'lib/kubemq/cq/query_message.rb', line 46 def id @id end |
#metadata ⇒ String?
Returns arbitrary metadata string.
46 |
# File 'lib/kubemq/cq/query_message.rb', line 46 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout, :cache_key, :cache_ttl |
#tags ⇒ Hash{String => String}
Returns user-defined key-value tags.
46 |
# File 'lib/kubemq/cq/query_message.rb', line 46 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout, :cache_key, :cache_ttl |
#timeout ⇒ Integer
Timeout is in milliseconds
Returns maximum time to wait for a response.
46 |
# File 'lib/kubemq/cq/query_message.rb', line 46 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout, :cache_key, :cache_ttl |