Class: KubeMQ::CQ::CommandResponse

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

Overview

Response returned by KubeMQ::CQClient#send_command after a subscriber processes the command.

Check #executed to confirm the command was handled successfully. If executed is false, inspect #error for the reason.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id:, request_id:, executed:, error: nil, timestamp: 0, tags: nil) ⇒ CommandResponse

Returns a new instance of CommandResponse.

Parameters:

  • client_id (String)

    responder's client ID

  • request_id (String)

    original request ID

  • executed (Boolean)

    whether the command was executed

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

    error description on failure

  • timestamp (Integer) (defaults to: 0)

    response timestamp (default: 0)

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

    key-value tags



34
35
36
37
38
39
40
41
# File 'lib/kubemq/cq/command_response.rb', line 34

def initialize(client_id:, request_id:, executed:, error: nil, timestamp: 0, tags: nil)
  @client_id = client_id
  @request_id = request_id
  @executed = executed
  @error = error
  @timestamp = timestamp
  @tags = tags || {}
end

Instance Attribute Details

#client_idString (readonly)

Returns the responder's client identifier.

Returns:

  • (String)

    the responder's client identifier



26
27
28
# File 'lib/kubemq/cq/command_response.rb', line 26

def client_id
  @client_id
end

#errorString? (readonly)

Returns error description if execution failed.

Returns:

  • (String, nil)

    error description if execution failed



26
# File 'lib/kubemq/cq/command_response.rb', line 26

attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags

#executedBoolean (readonly)

Returns true if the command was executed successfully.

Returns:

  • (Boolean)

    true if the command was executed successfully



26
# File 'lib/kubemq/cq/command_response.rb', line 26

attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags

#request_idString (readonly)

Returns the original command request identifier.

Returns:

  • (String)

    the original command request identifier



26
# File 'lib/kubemq/cq/command_response.rb', line 26

attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags

#tagsObject (readonly)

Returns the value of attribute tags.



26
# File 'lib/kubemq/cq/command_response.rb', line 26

attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags

#timestampInteger (readonly)

Returns broker-assigned response timestamp (Unix nanoseconds).

Returns:

  • (Integer)

    broker-assigned response timestamp (Unix nanoseconds)



26
# File 'lib/kubemq/cq/command_response.rb', line 26

attr_reader :client_id, :request_id, :executed, :error, :timestamp, :tags