Client SDKsNode.jsReference
RPC
Commands and queries — KubeMQ Node.js SDK reference.
Commands and queries share message factories (createCommand, createQuery). Responses are strongly typed CommandResponse / QueryResponse objects.
Commands
sendCommand
const response = await client.sendCommand(command: CommandMessage): Promise<CommandResponse>CommandMessage (via createCommand()):
| Field | Type | Required | Description |
|---|---|---|---|
channel | string | Yes | Target channel |
body | string | Uint8Array | Conditional | Payload |
metadata | string | Conditional | Metadata |
timeoutInSeconds | number | Yes | RPC timeout |
tags | Record<string, string> | No | Tags |
subscribeToCommands
client.subscribeToCommands(subscription: CommandSubscription): SubscriptionsendCommandResponse
await client.sendCommandResponse(response: CommandResponse): Promise<void>Queries
sendQuery
const response = await client.sendQuery(query: QueryMessage): Promise<QueryResponse>QueryMessage (via createQuery()) extends command fields with:
| Field | Type | Description |
|---|---|---|
cacheKey | string | Cache key |
cacheTtlInSeconds | number | TTL seconds |
subscribeToQueries
client.subscribeToQueries(subscription: QuerySubscription): SubscriptionsendQueryResponse
await client.sendQueryResponse(response: QueryResponse): Promise<void>Quick Usage
const response = await client.sendCommand(
createCommand({
channel: "svc.commands",
body: Buffer.from("ping"),
timeoutInSeconds: 5,
}),
);See Also
Was this page helpful?