Couchbase C Client  2.10.7
Asynchronous C Client for Couchbase
MULTICMD API

Detailed Description


Data Structure Documentation

◆ lcb_MULTICMD_CTX_st

struct lcb_MULTICMD_CTX_st

Multi Command Context API Some commands (notably, OBSERVE and its higher level equivalent, endue) are handled more efficiently at the cluster side by stuffing multiple items into a single packet.

This structure defines three function pointers to invoke. The addcmd() function will add a new command to the current packet, the done() function will schedule the packet(s) into the current scheduling context and the fail() function will destroy the context without progressing further.

Some commands will return an lcb_MULTICMD_CTX object to be used for this purpose:

lcb_MUTLICMD_CTX *ctx = lcb_observe3_ctxnew(instance);
lcb_CMDOBSERVE cmd = { 0 };
LCB_CMD_SET_KEY(&cmd, "key1", strlen("key1"));
ctx->addcmd(ctx, &cmd);
LCB_CMD_SET_KEY(&cmd.key, "key2", strlen("key2"));
ctx->addcmd(ctx, &cmd);
LCB_CMD_SET_KEY(&cmd.key, "key3", strlen("key3"));
ctx->addcmd(ctx, &cmd);
ctx->done(ctx);
lcb_wait(instance);

Data Fields

lcb_error_t(* addcmd )(struct lcb_MULTICMD_CTX_st *ctx, const lcb_CMDBASE *cmd)
 Add a command to the current context. More...
 
lcb_error_t(* done )(struct lcb_MULTICMD_CTX_st *ctx, const void *cookie)
 Indicate that no more commands are added to this context, and that the context should assemble the packets and place them in the current scheduling context. More...
 
void(* fail )(struct lcb_MULTICMD_CTX_st *ctx)
 Indicate that no more commands should be added to this context, and that the context should not add its contents to the packet queues, but rather release its resources. More...
 
void(* setspan )(struct lcb_MULTICMD_CTX_st *ctx, lcbtrace_SPAN *span)
 Associate parent tracing span with the group operation. More...
 

Field Documentation

◆ addcmd

lcb_error_t(* addcmd(struct lcb_MULTICMD_CTX_st *ctx, const lcb_CMDBASE *cmd)

Add a command to the current context.

Parameters
ctxthe context
cmdthe command to add. Note that cmd may be a subclass of lcb_CMDBASE
Returns
LCB_SUCCESS, or failure if a command could not be added.

◆ done

lcb_error_t(* done(struct lcb_MULTICMD_CTX_st *ctx, const void *cookie)

Indicate that no more commands are added to this context, and that the context should assemble the packets and place them in the current scheduling context.

Parameters
ctxThe multi context
cookieThe cookie for all commands
Returns
LCB_SUCCESS if scheduled successfully, or an error code if there was a problem constructing the packet(s).

◆ fail

void(* fail(struct lcb_MULTICMD_CTX_st *ctx)

Indicate that no more commands should be added to this context, and that the context should not add its contents to the packet queues, but rather release its resources.

Called if you don't want to actually perform the operations.

Parameters
ctx

◆ setspan

void(* setspan(struct lcb_MULTICMD_CTX_st *ctx, lcbtrace_SPAN *span)

Associate parent tracing span with the group operation.

Parameters
ctxThe multi context
spanParent span
lcb_CMDOBSERVE
Structure for an observe request.
Definition: couchbase.h:1777
lcb_CMDOBSERVE::key
lcb_KEYBUF key
The key for the document itself.
Definition: couchbase.h:1778
lcb_wait
lcb_error_t lcb_wait(lcb_t instance)
Wait for the execution of all batched requests.
LCB_CMD_SET_KEY
#define LCB_CMD_SET_KEY(cmd, keybuf, keylen)
Set the key for the command.
Definition: couchbase.h:556
lcb_observe3_ctxnew
lcb_MULTICMD_CTX * lcb_observe3_ctxnew(lcb_t instance)
Create a new multi context for an observe operation.