Couchbase C Client  2.10.6
Asynchronous C Client for Couchbase
MULTICMD API

Detailed Description


Data Structure Documentation

◆ lcb_MULTICMD_CTX

struct lcb_MULTICMD_CTX

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);
Examples
example/observe/observe.c.

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.
Examples
example/observe/observe.c.

◆ 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).
Examples
example/observe/observe.c.

◆ 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