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.
| Field | Type | Description |
|---|---|---|
id | String.t() | Auto-generated request ID |
channel | String.t() | Target channel |
metadata | String.t() | Optional metadata |
body | String.t() | binary() | Request payload |
timeout | pos_integer() | Response timeout in milliseconds |
client_id | String.t() | Sender client ID |
tags | map() | Optional key-value tags |
KubeMQ.CommandReceive
Received by the handler.
| Field | Type | Description |
|---|---|---|
id | String.t() | Request ID |
channel | String.t() | Source channel |
metadata | String.t() | Metadata |
body | String.t() | binary() | Request payload |
reply_channel | String.t() | Channel for sending the reply |
tags | map() | Key-value tags |
KubeMQ.CommandReply
Returned by the handler callback.
| Field | Type | Description |
|---|---|---|
request_id | String.t() | Matches the received command ID |
response_to | String.t() | Matches the reply channel |
executed | boolean() | Whether the command succeeded |
error | String.t() | Error message if failed |
metadata | String.t() | Optional response metadata |
KubeMQ.CommandResponse
Returned to the caller from send_command/2.
| Field | Type | Description |
|---|---|---|
command_id | String.t() | Command ID |
executed | boolean() | Success flag |
executed_at | integer() | Execution timestamp |
error | String.t() | Error if failed |
Query Structs
KubeMQ.Query
Sent by the caller. Supports server-side caching.
| Field | Type | Description |
|---|---|---|
id | String.t() | Auto-generated request ID |
channel | String.t() | Target channel |
metadata | String.t() | Optional metadata |
body | String.t() | binary() | Request payload |
timeout | pos_integer() | Response timeout in milliseconds |
cache_key | String.t() | Cache key for server-side caching |
cache_ttl | pos_integer() | Cache TTL in milliseconds |
client_id | String.t() | Sender client ID |
tags | map() | Optional key-value tags |
KubeMQ.QueryReply
Returned by the handler callback.
| Field | Type | Description |
|---|---|---|
request_id | String.t() | Matches the received query ID |
response_to | String.t() | Matches the reply channel |
executed | boolean() | Whether the query succeeded |
body | String.t() | binary() | Response data |
metadata | String.t() | Response metadata |
cache_hit | boolean() | Whether the response came from cache |
KubeMQ.QueryResponse
Returned to the caller from send_query/2.
| Field | Type | Description |
|---|---|---|
query_id | String.t() | Query ID |
executed | boolean() | Success flag |
body | String.t() | binary() | Response data |
metadata | String.t() | Response metadata |
cache_hit | boolean() | Cache hit flag |
error | String.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?