summaryrefslogtreecommitdiff
path: root/grpc/spm-cpp-include/grpcpp/generic/generic_stub.h
diff options
context:
space:
mode:
Diffstat (limited to 'grpc/spm-cpp-include/grpcpp/generic/generic_stub.h')
-rw-r--r--grpc/spm-cpp-include/grpcpp/generic/generic_stub.h61
1 files changed, 35 insertions, 26 deletions
diff --git a/grpc/spm-cpp-include/grpcpp/generic/generic_stub.h b/grpc/spm-cpp-include/grpcpp/generic/generic_stub.h
index e4576af1..e9564c33 100644
--- a/grpc/spm-cpp-include/grpcpp/generic/generic_stub.h
+++ b/grpc/spm-cpp-include/grpcpp/generic/generic_stub.h
@@ -22,6 +22,7 @@
#include <functional>
#include <grpcpp/client_context.h>
+#include <grpcpp/impl/codegen/stub_options.h>
#include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/async_stream.h>
#include <grpcpp/support/async_unary_call.h>
@@ -53,7 +54,8 @@ class TemplatedGenericStub final {
std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
PrepareCall(ClientContext* context, const std::string& method,
::grpc::CompletionQueue* cq) {
- return CallInternal(channel_.get(), context, method, cq, false, nullptr);
+ return CallInternal(channel_.get(), context, method, /*options=*/{}, cq,
+ false, nullptr);
}
/// Setup a unary call to a named method \a method using \a context, and don't
@@ -67,6 +69,7 @@ class TemplatedGenericStub final {
internal::ClientAsyncResponseReaderHelper::Create<ResponseType>(
channel_.get(), cq,
grpc::internal::RpcMethod(method.c_str(),
+ /*suffix_for_stats=*/nullptr,
grpc::internal::RpcMethod::NORMAL_RPC),
context, request));
}
@@ -80,7 +83,8 @@ class TemplatedGenericStub final {
std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>> Call(
ClientContext* context, const std::string& method,
::grpc::CompletionQueue* cq, void* tag) {
- return CallInternal(channel_.get(), context, method, cq, true, tag);
+ return CallInternal(channel_.get(), context, method, /*options=*/{}, cq,
+ true, tag);
}
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
@@ -89,7 +93,7 @@ class TemplatedGenericStub final {
void UnaryCall(ClientContext* context, const std::string& method,
const RequestType* request, ResponseType* response,
std::function<void(grpc::Status)> on_completion) {
- UnaryCallInternal(context, method, request, response,
+ UnaryCallInternal(context, method, /*options=*/{}, request, response,
std::move(on_completion));
}
@@ -100,7 +104,8 @@ class TemplatedGenericStub final {
void PrepareUnaryCall(ClientContext* context, const std::string& method,
const RequestType* request, ResponseType* response,
ClientUnaryReactor* reactor) {
- PrepareUnaryCallInternal(context, method, request, response, reactor);
+ PrepareUnaryCallInternal(context, method, /*options=*/{}, request, response,
+ reactor);
}
/// Setup a call to a named method \a method using \a context and tied to
@@ -109,7 +114,7 @@ class TemplatedGenericStub final {
void PrepareBidiStreamingCall(
ClientContext* context, const std::string& method,
ClientBidiReactor<RequestType, ResponseType>* reactor) {
- PrepareBidiStreamingCallInternal(context, method, reactor);
+ PrepareBidiStreamingCallInternal(context, method, /*options=*/{}, reactor);
}
#endif
@@ -123,9 +128,10 @@ class TemplatedGenericStub final {
/// Setup and start a unary call to a named method \a method using
/// \a context and specifying the \a request and \a response buffers.
void UnaryCall(ClientContext* context, const std::string& method,
- const RequestType* request, ResponseType* response,
+ StubOptions options, const RequestType* request,
+ ResponseType* response,
std::function<void(grpc::Status)> on_completion) {
- stub_->UnaryCallInternal(context, method, request, response,
+ stub_->UnaryCallInternal(context, method, options, request, response,
std::move(on_completion));
}
@@ -134,19 +140,20 @@ class TemplatedGenericStub final {
/// Like any other reactor-based RPC, it will not be activated until
/// StartCall is invoked on its reactor.
void PrepareUnaryCall(ClientContext* context, const std::string& method,
- const RequestType* request, ResponseType* response,
- ClientUnaryReactor* reactor) {
- stub_->PrepareUnaryCallInternal(context, method, request, response,
- reactor);
+ StubOptions options, const RequestType* request,
+ ResponseType* response, ClientUnaryReactor* reactor) {
+ stub_->PrepareUnaryCallInternal(context, method, options, request,
+ response, reactor);
}
/// Setup a call to a named method \a method using \a context and tied to
/// \a reactor . Like any other bidi streaming RPC, it will not be activated
/// until StartCall is invoked on its reactor.
void PrepareBidiStreamingCall(
- ClientContext* context, const std::string& method,
+ ClientContext* context, const std::string& method, StubOptions options,
ClientBidiReactor<RequestType, ResponseType>* reactor) {
- stub_->PrepareBidiStreamingCallInternal(context, method, reactor);
+ stub_->PrepareBidiStreamingCallInternal(context, method, options,
+ reactor);
}
private:
@@ -162,48 +169,50 @@ class TemplatedGenericStub final {
std::shared_ptr<grpc::ChannelInterface> channel_;
void UnaryCallInternal(ClientContext* context, const std::string& method,
- const RequestType* request, ResponseType* response,
+ StubOptions options, const RequestType* request,
+ ResponseType* response,
std::function<void(grpc::Status)> on_completion) {
internal::CallbackUnaryCall(
channel_.get(),
- grpc::internal::RpcMethod(method.c_str(),
+ grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
grpc::internal::RpcMethod::NORMAL_RPC),
context, request, response, std::move(on_completion));
}
void PrepareUnaryCallInternal(ClientContext* context,
- const std::string& method,
+ const std::string& method, StubOptions options,
const RequestType* request,
ResponseType* response,
ClientUnaryReactor* reactor) {
internal::ClientCallbackUnaryFactory::Create<RequestType, ResponseType>(
channel_.get(),
- grpc::internal::RpcMethod(method.c_str(),
+ grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
grpc::internal::RpcMethod::NORMAL_RPC),
context, request, response, reactor);
}
void PrepareBidiStreamingCallInternal(
- ClientContext* context, const std::string& method,
+ ClientContext* context, const std::string& method, StubOptions options,
ClientBidiReactor<RequestType, ResponseType>* reactor) {
internal::ClientCallbackReaderWriterFactory<RequestType, ResponseType>::
Create(channel_.get(),
grpc::internal::RpcMethod(
- method.c_str(), grpc::internal::RpcMethod::BIDI_STREAMING),
+ method.c_str(), options.suffix_for_stats(),
+ grpc::internal::RpcMethod::BIDI_STREAMING),
context, reactor);
}
std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
CallInternal(grpc::ChannelInterface* channel, ClientContext* context,
- const std::string& method, ::grpc::CompletionQueue* cq,
- bool start, void* tag) {
+ const std::string& method, StubOptions options,
+ ::grpc::CompletionQueue* cq, bool start, void* tag) {
return std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>(
internal::ClientAsyncReaderWriterFactory<RequestType, ResponseType>::
- Create(
- channel, cq,
- grpc::internal::RpcMethod(
- method.c_str(), grpc::internal::RpcMethod::BIDI_STREAMING),
- context, start, tag));
+ Create(channel, cq,
+ grpc::internal::RpcMethod(
+ method.c_str(), options.suffix_for_stats(),
+ grpc::internal::RpcMethod::BIDI_STREAMING),
+ context, start, tag));
}
};