Class: KubeMQ::CQ::CommandReceived

Inherits:
Object
  • Object
show all
Defined in:
lib/kubemq/cq/command_received.rb

Overview

A command received by a subscriber via KubeMQ::CQClient#subscribe_to_commands.

After processing, use the #reply_channel and #id to construct a CommandResponseMessage and send it back via KubeMQ::CQClient#send_response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, channel:, metadata:, body:, reply_channel:, tags:, timeout: 0, client_id: nil, **_) ⇒ CommandReceived

Returns a new instance of CommandReceived.

Parameters:

  • id (String)

    request identifier

  • channel (String)

    source channel name

  • metadata (String)

    command metadata

  • body (String)

    command payload

  • reply_channel (String)

    response channel

  • tags (Hash{String => String}, nil)

    key-value tags

  • timeout (Integer) (defaults to: 0)

    sender timeout in milliseconds (default: 0)

  • client_id (String, nil) (defaults to: nil)

    sender's client ID



40
41
42
43
44
45
46
47
48
49
# File 'lib/kubemq/cq/command_received.rb', line 40

def initialize(id:, channel:, metadata:, body:, reply_channel:, tags:, timeout: 0, client_id: nil, **_)
  @id = id
  @channel = channel
  @metadata = 
  @body = body
  @reply_channel = reply_channel
  @tags = tags || {}
  @timeout = timeout
  @client_id = client_id
end

Instance Attribute Details

#bodyString (readonly)

Returns command payload (binary).

Returns:

  • (String)

    command payload (binary)



30
# File 'lib/kubemq/cq/command_received.rb', line 30

attr_reader :id, :channel, :metadata, :body, :reply_channel, :tags, :timeout, :client_id

#channelString (readonly)

Returns the channel the command was sent to.

Returns:

  • (String)

    the channel the command was sent to



30
# File 'lib/kubemq/cq/command_received.rb', line 30

attr_reader :id, :channel, :metadata, :body, :reply_channel, :tags, :timeout, :client_id

#client_idObject (readonly)

Returns the value of attribute client_id.



30
# File 'lib/kubemq/cq/command_received.rb', line 30

attr_reader :id, :channel, :metadata, :body, :reply_channel, :tags, :timeout, :client_id

#idString (readonly)

Returns request identifier (use as request_id in the response).

Returns:

  • (String)

    request identifier (use as request_id in the response)



30
31
32
# File 'lib/kubemq/cq/command_received.rb', line 30

def id
  @id
end

#metadataString (readonly)

Returns command metadata.

Returns:

  • (String)

    command metadata



30
# File 'lib/kubemq/cq/command_received.rb', line 30

attr_reader :id, :channel, :metadata, :body, :reply_channel, :tags, :timeout, :client_id

#reply_channelString (readonly)

Returns channel to send the response back on.

Returns:

  • (String)

    channel to send the response back on



30
# File 'lib/kubemq/cq/command_received.rb', line 30

attr_reader :id, :channel, :metadata, :body, :reply_channel, :tags, :timeout, :client_id

#tagsHash{String => String} (readonly)

Returns user-defined key-value tags.

Returns:

  • (Hash{String => String})

    user-defined key-value tags



30
# File 'lib/kubemq/cq/command_received.rb', line 30

attr_reader :id, :channel, :metadata, :body, :reply_channel, :tags, :timeout, :client_id

#timeoutInteger (readonly)

Returns original timeout from the sender (milliseconds).

Returns:

  • (Integer)

    original timeout from the sender (milliseconds)



30
# File 'lib/kubemq/cq/command_received.rb', line 30

attr_reader :id, :channel, :metadata, :body, :reply_channel, :tags, :timeout, :client_id