Exemplo n.º 1
0
void ServiceEntryPointMock::run(transport::SessionHandle session) {
    Message inMessage;
    while (true) {
        {
            stdx::lock_guard<stdx::mutex> lk(_shutdownLock);
            if (_inShutdown)
                break;
        }

        // sourceMessage()
        if (!session->sourceMessage(&inMessage).wait().isOK()) {
            break;
        }

        auto resp = handleRequest(nullptr, inMessage, session->remote());

        // sinkMessage()
        if (!session->sinkMessage(resp.response).wait().isOK()) {
            break;
        }
    }
}
Exemplo n.º 2
0
void OpQueryReplyBuilder::send(const transport::SessionHandle& session,
                               int queryResultFlags,
                               const Message& requestMsg,
                               int nReturned,
                               int startingFrom,
                               long long cursorId) {
    Message response;
    putInMessage(&response, queryResultFlags, nReturned, startingFrom, cursorId);

    response.header().setId(nextMessageId());
    response.header().setResponseToMsgId(requestMsg.header().getId());

    uassertStatusOK(session->sinkMessage(response).wait());
}
Exemplo n.º 3
0
void Client::initThread(StringData desc,
                        ServiceContext* service,
                        transport::SessionHandle session) {
    invariant(!haveClient());

    std::string fullDesc;
    if (session) {
        fullDesc = str::stream() << desc << session->id();
    } else {
        fullDesc = desc.toString();
    }

    setThreadName(fullDesc);

    // Create the client obj, attach to thread
    currentClient = service->makeClient(fullDesc, std::move(session));
}
Exemplo n.º 4
0
void Client::initThread(const char* desc,
                        ServiceContext* service,
                        transport::SessionHandle session) {
    invariant(currentClient.getMake()->get() == nullptr);

    std::string fullDesc;
    if (session) {
        fullDesc = str::stream() << desc << session->id();
    } else {
        fullDesc = desc;
    }

    setThreadName(fullDesc.c_str());

    // Create the client obj, attach to thread
    *currentClient.get() = service->makeClient(fullDesc, std::move(session));
}