|
|
|
@ -24,6 +24,7 @@ |
|
|
|
|
#include <sstream> |
|
|
|
|
#include <string> |
|
|
|
|
#include <thread> |
|
|
|
|
#include <utility> |
|
|
|
|
#include <vector> |
|
|
|
|
|
|
|
|
|
#include <grpc/grpc.h> |
|
|
|
@ -78,7 +79,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { |
|
|
|
|
response_(), |
|
|
|
|
next_state_(State::READY), |
|
|
|
|
callback_(on_done), |
|
|
|
|
next_issue_(next_issue), |
|
|
|
|
next_issue_(std::move(next_issue)), |
|
|
|
|
prepare_req_(prepare_req) {} |
|
|
|
|
~ClientRpcContextUnaryImpl() override {} |
|
|
|
|
void Start(CompletionQueue* cq, const ClientConfig& config) override { |
|
|
|
@ -298,7 +299,7 @@ class AsyncClient : public ClientImpl<StubType, RequestType> { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static std::unique_ptr<BenchmarkService::Stub> BenchmarkStubCreator( |
|
|
|
|
std::shared_ptr<Channel> ch) { |
|
|
|
|
const std::shared_ptr<Channel>& ch) { |
|
|
|
|
return BenchmarkService::NewStub(ch); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -313,7 +314,7 @@ class AsyncUnaryClient final |
|
|
|
|
~AsyncUnaryClient() override {} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
static void CheckDone(grpc::Status s, SimpleResponse* response, |
|
|
|
|
static void CheckDone(const grpc::Status& s, SimpleResponse* response, |
|
|
|
|
HistogramEntry* entry) { |
|
|
|
|
entry->set_status(s.error_code()); |
|
|
|
|
} |
|
|
|
@ -326,7 +327,7 @@ class AsyncUnaryClient final |
|
|
|
|
std::function<gpr_timespec()> next_issue, |
|
|
|
|
const SimpleRequest& req) { |
|
|
|
|
return new ClientRpcContextUnaryImpl<SimpleRequest, SimpleResponse>( |
|
|
|
|
stub, req, next_issue, AsyncUnaryClient::PrepareReq, |
|
|
|
|
stub, req, std::move(next_issue), AsyncUnaryClient::PrepareReq, |
|
|
|
|
AsyncUnaryClient::CheckDone); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -349,7 +350,7 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext { |
|
|
|
|
response_(), |
|
|
|
|
next_state_(State::INVALID), |
|
|
|
|
callback_(on_done), |
|
|
|
|
next_issue_(next_issue), |
|
|
|
|
next_issue_(std::move(next_issue)), |
|
|
|
|
prepare_req_(prepare_req), |
|
|
|
|
coalesce_(false) {} |
|
|
|
|
~ClientRpcContextStreamingPingPongImpl() override {} |
|
|
|
@ -497,7 +498,7 @@ class AsyncStreamingPingPongClient final |
|
|
|
|
~AsyncStreamingPingPongClient() override {} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
static void CheckDone(grpc::Status s, SimpleResponse* response) {} |
|
|
|
|
static void CheckDone(const grpc::Status& s, SimpleResponse* response) {} |
|
|
|
|
static std::unique_ptr< |
|
|
|
|
grpc::ClientAsyncReaderWriter<SimpleRequest, SimpleResponse>> |
|
|
|
|
PrepareReq(BenchmarkService::Stub* stub, grpc::ClientContext* ctx, |
|
|
|
@ -510,7 +511,8 @@ class AsyncStreamingPingPongClient final |
|
|
|
|
const SimpleRequest& req) { |
|
|
|
|
return new ClientRpcContextStreamingPingPongImpl<SimpleRequest, |
|
|
|
|
SimpleResponse>( |
|
|
|
|
stub, req, next_issue, AsyncStreamingPingPongClient::PrepareReq, |
|
|
|
|
stub, req, std::move(next_issue), |
|
|
|
|
AsyncStreamingPingPongClient::PrepareReq, |
|
|
|
|
AsyncStreamingPingPongClient::CheckDone); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -533,7 +535,7 @@ class ClientRpcContextStreamingFromClientImpl : public ClientRpcContext { |
|
|
|
|
response_(), |
|
|
|
|
next_state_(State::INVALID), |
|
|
|
|
callback_(on_done), |
|
|
|
|
next_issue_(next_issue), |
|
|
|
|
next_issue_(std::move(next_issue)), |
|
|
|
|
prepare_req_(prepare_req) {} |
|
|
|
|
~ClientRpcContextStreamingFromClientImpl() override {} |
|
|
|
|
void Start(CompletionQueue* cq, const ClientConfig& config) override { |
|
|
|
@ -628,7 +630,7 @@ class AsyncStreamingFromClientClient final |
|
|
|
|
~AsyncStreamingFromClientClient() override {} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
static void CheckDone(grpc::Status s, SimpleResponse* response) {} |
|
|
|
|
static void CheckDone(const grpc::Status& s, SimpleResponse* response) {} |
|
|
|
|
static std::unique_ptr<grpc::ClientAsyncWriter<SimpleRequest>> PrepareReq( |
|
|
|
|
BenchmarkService::Stub* stub, grpc::ClientContext* ctx, |
|
|
|
|
SimpleResponse* resp, CompletionQueue* cq) { |
|
|
|
@ -640,7 +642,8 @@ class AsyncStreamingFromClientClient final |
|
|
|
|
const SimpleRequest& req) { |
|
|
|
|
return new ClientRpcContextStreamingFromClientImpl<SimpleRequest, |
|
|
|
|
SimpleResponse>( |
|
|
|
|
stub, req, next_issue, AsyncStreamingFromClientClient::PrepareReq, |
|
|
|
|
stub, req, std::move(next_issue), |
|
|
|
|
AsyncStreamingFromClientClient::PrepareReq, |
|
|
|
|
AsyncStreamingFromClientClient::CheckDone); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -663,7 +666,7 @@ class ClientRpcContextStreamingFromServerImpl : public ClientRpcContext { |
|
|
|
|
response_(), |
|
|
|
|
next_state_(State::INVALID), |
|
|
|
|
callback_(on_done), |
|
|
|
|
next_issue_(next_issue), |
|
|
|
|
next_issue_(std::move(next_issue)), |
|
|
|
|
prepare_req_(prepare_req) {} |
|
|
|
|
~ClientRpcContextStreamingFromServerImpl() override {} |
|
|
|
|
void Start(CompletionQueue* cq, const ClientConfig& config) override { |
|
|
|
@ -742,7 +745,7 @@ class AsyncStreamingFromServerClient final |
|
|
|
|
~AsyncStreamingFromServerClient() override {} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
static void CheckDone(grpc::Status s, SimpleResponse* response) {} |
|
|
|
|
static void CheckDone(const grpc::Status& s, SimpleResponse* response) {} |
|
|
|
|
static std::unique_ptr<grpc::ClientAsyncReader<SimpleResponse>> PrepareReq( |
|
|
|
|
BenchmarkService::Stub* stub, grpc::ClientContext* ctx, |
|
|
|
|
const SimpleRequest& req, CompletionQueue* cq) { |
|
|
|
@ -754,7 +757,8 @@ class AsyncStreamingFromServerClient final |
|
|
|
|
const SimpleRequest& req) { |
|
|
|
|
return new ClientRpcContextStreamingFromServerImpl<SimpleRequest, |
|
|
|
|
SimpleResponse>( |
|
|
|
|
stub, req, next_issue, AsyncStreamingFromServerClient::PrepareReq, |
|
|
|
|
stub, req, std::move(next_issue), |
|
|
|
|
AsyncStreamingFromServerClient::PrepareReq, |
|
|
|
|
AsyncStreamingFromServerClient::CheckDone); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -775,9 +779,9 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext { |
|
|
|
|
req_(req), |
|
|
|
|
response_(), |
|
|
|
|
next_state_(State::INVALID), |
|
|
|
|
callback_(on_done), |
|
|
|
|
next_issue_(next_issue), |
|
|
|
|
prepare_req_(prepare_req) {} |
|
|
|
|
callback_(std::move(on_done)), |
|
|
|
|
next_issue_(std::move(next_issue)), |
|
|
|
|
prepare_req_(std::move(prepare_req)) {} |
|
|
|
|
~ClientRpcContextGenericStreamingImpl() override {} |
|
|
|
|
void Start(CompletionQueue* cq, const ClientConfig& config) override { |
|
|
|
|
GPR_ASSERT(!config.use_coalesce_api()); // not supported yet.
|
|
|
|
@ -891,7 +895,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static std::unique_ptr<grpc::GenericStub> GenericStubCreator( |
|
|
|
|
std::shared_ptr<Channel> ch) { |
|
|
|
|
const std::shared_ptr<Channel>& ch) { |
|
|
|
|
return std::unique_ptr<grpc::GenericStub>(new grpc::GenericStub(ch)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -907,7 +911,7 @@ class GenericAsyncStreamingClient final |
|
|
|
|
~GenericAsyncStreamingClient() override {} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
static void CheckDone(grpc::Status s, ByteBuffer* response) {} |
|
|
|
|
static void CheckDone(const grpc::Status& s, ByteBuffer* response) {} |
|
|
|
|
static std::unique_ptr<grpc::GenericClientAsyncReaderWriter> PrepareReq( |
|
|
|
|
grpc::GenericStub* stub, grpc::ClientContext* ctx, |
|
|
|
|
const grpc::string& method_name, CompletionQueue* cq) { |
|
|
|
@ -918,7 +922,8 @@ class GenericAsyncStreamingClient final |
|
|
|
|
std::function<gpr_timespec()> next_issue, |
|
|
|
|
const ByteBuffer& req) { |
|
|
|
|
return new ClientRpcContextGenericStreamingImpl( |
|
|
|
|
stub, req, next_issue, GenericAsyncStreamingClient::PrepareReq, |
|
|
|
|
stub, req, std::move(next_issue), |
|
|
|
|
GenericAsyncStreamingClient::PrepareReq, |
|
|
|
|
GenericAsyncStreamingClient::CheckDone); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|