Class: KubeMQ::CQ::CommandMessage
- Inherits:
-
Object
- Object
- KubeMQ::CQ::CommandMessage
- Defined in:
- lib/kubemq/cq/command_message.rb
Overview
Outbound command message for the request/reply (fire-and-confirm) pattern.
Construct a CommandMessage and pass it to KubeMQ::CQClient#send_command.
The broker forwards the command to a subscriber and returns a
CommandResponse indicating whether it was executed.
Instance Attribute Summary collapse
-
#body ⇒ String?
Message payload (binary-safe).
-
#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) ⇒ CommandMessage
constructor
A new instance of CommandMessage.
Constructor Details
#initialize(channel:, timeout:, metadata: nil, body: nil, tags: nil, id: nil) ⇒ CommandMessage
timeout is in milliseconds
Returns a new instance of CommandMessage.
49 50 51 52 53 54 55 56 |
# File 'lib/kubemq/cq/command_message.rb', line 49 def initialize(channel:, timeout:, metadata: nil, body: nil, tags: nil, id: nil) @id = id || SecureRandom.uuid @channel = channel @timeout = timeout @metadata = @body = body @tags = || {} end |
Instance Attribute Details
#body ⇒ String?
Returns message payload (binary-safe).
40 |
# File 'lib/kubemq/cq/command_message.rb', line 40 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout |
#channel ⇒ String
Returns target channel name.
40 |
# File 'lib/kubemq/cq/command_message.rb', line 40 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout |
#id ⇒ String
Returns unique message identifier (auto-generated UUID if not provided).
40 41 42 |
# File 'lib/kubemq/cq/command_message.rb', line 40 def id @id end |
#metadata ⇒ String?
Returns arbitrary metadata string.
40 |
# File 'lib/kubemq/cq/command_message.rb', line 40 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout |
#tags ⇒ Hash{String => String}
Returns user-defined key-value tags.
40 |
# File 'lib/kubemq/cq/command_message.rb', line 40 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout |
#timeout ⇒ Integer
Timeout is in milliseconds
Returns maximum time to wait for a response.
40 |
# File 'lib/kubemq/cq/command_message.rb', line 40 attr_accessor :id, :channel, :metadata, :body, :tags, :timeout |