예제 #1
0
SV*
PLCB_op_observe(PLCB_t *object, plcb_SINGLEOP *opinfo)
{
    lcb_CMDOBSERVE obscmd = { 0 };
    lcb_MULTICMD_CTX *mctx;
    lcb_error_t err = LCB_SUCCESS;

    key_from_so(opinfo, &obscmd);
    PLCB_args_observe(object, opinfo, &obscmd);

    mctx = lcb_observe3_ctxnew(object->instance);
    if (!mctx) {
        err = LCB_CLIENT_ENOMEM;
        goto GT_DONE;
    }

    err = mctx->addcmd(mctx, (lcb_CMDBASE*)&obscmd);
    if (err == LCB_SUCCESS) {
        err = mctx->done(mctx, opinfo->cookie);
    } else {
        mctx->fail(mctx);
    }

    GT_DONE:
    return plcb_opctx_return(opinfo, err);
}
예제 #2
0
lcb_MULTICMD_CTX *
lcb_observe_ctx_dur_new(lcb_t instance)
{
    lcb_MULTICMD_CTX *mctx = lcb_observe3_ctxnew(instance);
    if (mctx) {
        OBSERVECTX *ctx = CTX_FROM_MULTI(mctx);
        ctx->oflags |= F_DURABILITY;
    }
    return mctx;
}
예제 #3
0
LIBCOUCHBASE_API
lcb_error_t lcb_observe(lcb_t instance,
    const void *command_cookie, lcb_size_t num,
    const lcb_observe_cmd_t *const *items)
{
    unsigned ii;
    lcb_error_t err;
    lcb_MULTICMD_CTX *mctx;

    lcb_sched_enter(instance);

    mctx = lcb_observe3_ctxnew(instance);
    if (mctx == NULL) {
        return LCB_CLIENT_ENOMEM;
    }

    for (ii = 0; ii < num; ii++) {
        lcb_CMDOBSERVE cmd = { 0 };
        const lcb_observe_cmd_t *src = items[ii];
        if (src->version == 1 && (src->v.v1.options & LCB_OBSERVE_MASTER_ONLY)) {
            cmd.cmdflags |= LCB_CMDOBSERVE_F_MASTER_ONLY;
        }
        LCB_KREQ_SIMPLE(&cmd.key, src->v.v0.key, src->v.v0.nkey);
        LCB_KREQ_SIMPLE(&cmd._hashkey, src->v.v0.hashkey, src->v.v0.nhashkey);

        err = mctx->addcmd(mctx, (lcb_CMDBASE *)&cmd);
        if (err != LCB_SUCCESS) {
            mctx->fail(mctx);
            return err;
        }
    }
    lcb_sched_enter(instance);
    mctx->done(mctx, command_cookie);
    lcb_sched_leave(instance);
    SYNCMODE_INTERCEPT(instance)
}