当前位置: 首页>>代码示例>>C++>>正文


C++ View::setOperation方法代码示例

本文整理汇总了C++中msgdata::View::setOperation方法的典型用法代码示例。如果您正苦于以下问题:C++ View::setOperation方法的具体用法?C++ View::setOperation怎么用?C++ View::setOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在msgdata::View的用法示例。


在下文中一共展示了View::setOperation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: done

Message CommandReplyBuilder::done() {
    invariant(_state == State::kOutputDocs);
    MsgData::View msg = _builder.buf();
    msg.setLen(_builder.len());
    msg.setOperation(dbCommandReply);
    _builder.decouple();                     // release ownership from BufBuilder
    _message.setData(msg.view2ptr(), true);  // transfer ownership to Message
    _state = State::kDone;
    return std::move(_message);
}
开发者ID:hongz1,项目名称:mongo,代码行数:10,代码来源:command_reply_builder.cpp

示例2: opCommandRequestFromOpMsgRequest

Message opCommandRequestFromOpMsgRequest(const OpMsgRequest& request) {
    const auto commandName = request.getCommandName();

    BufBuilder builder;
    builder.skip(mongo::MsgData::MsgDataHeaderSize);  // Leave room for message header.
    builder.appendStr(request.getDatabase());
    builder.appendStr(commandName);

    // OP_COMMAND is only used when communicating with 3.4 nodes and they serialize their metadata
    // fields differently. In addition to field-level differences, some generic arguments are pulled
    // out to a metadata object, separate from the body. We do all down-conversion here so that the
    // rest of the code only has to deal with the current format.
    BSONObjBuilder metadataBuilder;  // Will be appended to the message after we finish the body.
    {
        BSONObjBuilder bodyBuilder(builder);
        for (auto elem : request.body) {
            const auto fieldName = elem.fieldNameStringData();
            if (fieldName == "$configServerState") {
                metadataBuilder.appendAs(elem, "configsvr");
            } else if (fieldName == "$readPreference") {
                BSONObjBuilder ssmBuilder(metadataBuilder.subobjStart("$ssm"));
                ssmBuilder.append(elem);
                ssmBuilder.append("$secondaryOk",
                                  uassertStatusOK(ReadPreferenceSetting::fromInnerBSON(elem))
                                      .canRunOnSecondary());
            } else if (fieldName == "$db") {
                // skip
            } else if (fieldGoesInMetadata(commandName, fieldName)) {
                metadataBuilder.append(elem);
            } else {
                bodyBuilder.append(elem);
            }
        }
        for (auto&& seq : request.sequences) {
            invariant(seq.name.find('.') == std::string::npos);  // Only support top-level for now.
            dassert(!bodyBuilder.asTempObj().hasField(seq.name));
            bodyBuilder.append(seq.name, seq.objs);
        }
    }
    metadataBuilder.obj().appendSelfToBufBuilder(builder);

    MsgData::View msg = builder.buf();
    msg.setLen(builder.len());
    msg.setOperation(dbCommand);
    return Message(builder.release());
}
开发者ID:louiswilliams,项目名称:mongo,代码行数:46,代码来源:command_request_builder.cpp

示例3: handleRequest

DbResponse ServiceEntryPointMock::handleRequest(OperationContext* opCtx,
                                                const Message& request,
                                                const HostAndPort& client) {
    // Need to set up our { ok : 1 } response.
    BufBuilder b{};

    // Leave room for the message header
    b.skip(mongo::MsgData::MsgDataHeaderSize);

    // Add our response
    auto okObj = BSON("ok" << 1.0);
    okObj.appendSelfToBufBuilder(b);

    // Add some metadata
    auto metadata = BSONObj();
    metadata.appendSelfToBufBuilder(b);

    // Set Message header fields
    MsgData::View msg = b.buf();
    msg.setLen(b.len());
    msg.setOperation(dbCommandReply);

    return {Message(b.release()), ""};
}
开发者ID:dgottlieb,项目名称:mongo,代码行数:24,代码来源:service_entry_point_mock.cpp


注:本文中的msgdata::View::setOperation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。