KubeMQ
Client SDKsElixirReference

RPC

Command and query structs for synchronous request/response — KubeMQ Elixir SDK reference.

Which to use

This page is the field-level struct reference for Command/Query/CommandReply/QueryReply. For the task-oriented walkthroughs of handling incoming requests, see Handle Command and Handle Query.

RPC (Remote Procedure Call) provides synchronous request/response messaging through Commands (fire-and-wait, no data return) and Queries (request data with optional server-side caching).

Command Structs

KubeMQ.Command

Sent by the caller.

FieldTypeDescription
idString.t()Auto-generated request ID
channelString.t()Target channel
metadataString.t()Optional metadata
bodyString.t() | binary()Request payload
timeoutpos_integer()Response timeout in milliseconds
client_idString.t()Sender client ID
tagsmap()Optional key-value tags

KubeMQ.CommandReceive

Received by the handler.

FieldTypeDescription
idString.t()Request ID
channelString.t()Source channel
metadataString.t()Metadata
bodyString.t() | binary()Request payload
reply_channelString.t()Channel for sending the reply
tagsmap()Key-value tags

KubeMQ.CommandReply

Returned by the handler callback.

FieldTypeDescription
request_idString.t()Matches the received command ID
response_toString.t()Matches the reply channel
executedboolean()Whether the command succeeded
errorString.t()Error message if failed
metadataString.t()Optional response metadata

KubeMQ.CommandResponse

Returned to the caller from send_command/2.

FieldTypeDescription
command_idString.t()Command ID
executedboolean()Success flag
executed_atinteger()Execution timestamp
errorString.t()Error if failed

Query Structs

KubeMQ.Query

Sent by the caller. Supports server-side caching.

FieldTypeDescription
idString.t()Auto-generated request ID
channelString.t()Target channel
metadataString.t()Optional metadata
bodyString.t() | binary()Request payload
timeoutpos_integer()Response timeout in milliseconds
cache_keyString.t()Cache key for server-side caching
cache_ttlpos_integer()Cache TTL in milliseconds
client_idString.t()Sender client ID
tagsmap()Optional key-value tags

KubeMQ.QueryReply

Returned by the handler callback.

FieldTypeDescription
request_idString.t()Matches the received query ID
response_toString.t()Matches the reply channel
executedboolean()Whether the query succeeded
bodyString.t() | binary()Response data
metadataString.t()Response metadata
cache_hitboolean()Whether the response came from cache

KubeMQ.QueryResponse

Returned to the caller from send_query/2.

FieldTypeDescription
query_idString.t()Query ID
executedboolean()Success flag
bodyString.t() | binary()Response data
metadataString.t()Response metadata
cache_hitboolean()Cache hit flag
errorString.t()Error if failed

Command Example

{:ok, sub} = KubeMQ.Client.subscribe_to_commands(client, "orders",
  on_command: fn cmd ->
    KubeMQ.CommandReply.new(
      request_id: cmd.id,
      response_to: cmd.reply_channel,
      executed: true
    )
  end
)

cmd = KubeMQ.Command.new(channel: "orders", body: "process", timeout: 10_000)
{:ok, resp} = KubeMQ.Client.send_command(client, cmd)

Query with Caching

query = KubeMQ.Query.new(
  channel: "products",
  body: "sku-123",
  timeout: 10_000,
  cache_key: "product-sku-123",
  cache_ttl: 60_000
)

{:ok, resp} = KubeMQ.Client.send_query(client, query)
IO.puts("Cache hit: #{resp.cache_hit}")

See Also

Was this page helpful?

On this page