KubeMQ
Client SDKsGoReference

RPC

KubeMQ Go SDK reference for Commands and Queries, covering request-reply methods, timeouts, and response caching.

Commands and queries implement request–reply over channels. Commands expect a single response; queries return data payloads and support optional response caching.

Commands

SendCommand

func (c *Client) SendCommand(ctx context.Context, command *Command) (*CommandResponse, error)

Sends a command and blocks until a response arrives or timeout elapses.

Parameters:

NameTypeRequiredDescription
ctxcontext.ContextYesOverall deadline
command*CommandYesChannel, body/metadata, SetTimeout, tags

Returns: *CommandResponse — execution metadata and payload from responder.

SubscribeToCommands

func (c *Client) SubscribeToCommands(ctx context.Context, channel, group string, opts ...SubscribeOption) (*Subscription, error)

Receives incoming commands for a service. Use handlers configured via SubscribeOption.

SendCommandResponse

func (c *Client) SendCommandResponse(ctx context.Context, response *CommandReply) error

Replies to a command received in the subscription callback.

Queries

SendQuery

func (c *Client) SendQuery(ctx context.Context, query *Query) (*QueryResponse, error)

Sends a query and waits for a typed response. Use SetCacheKey / SetCacheTTL on the Query for server-side cache hints.

SubscribeToQueries

func (c *Client) SubscribeToQueries(ctx context.Context, channel, group string, opts ...SubscribeOption) (*Subscription, error)

Subscribes as a query worker; analogous to commands with different protobuf routing.

SendQueryResponse

func (c *Client) SendQueryResponse(ctx context.Context, response *QueryReply) error

Returns data and metadata to the caller of SendQuery.

Message helpers

TypeFactoryNotes
CommandNewCommand()Timeout required for server routing
QueryNewQuery()Adds cache key/TTL fields

Quick Usage

rpc.go
cmd := kubemq.NewCommand()
cmd.SetChannel("svc.commands")
cmd.SetBody([]byte("ping"))
cmd.SetTimeout(5 * time.Second)

resp, err := client.SendCommand(ctx, cmd)
if err != nil {
    return err
}
_ = resp.Executed

See Also

Was this page helpful?

On this page