Go to the documentation of this file.
19 #ifndef GRPCPP_GENERIC_GENERIC_STUB_H
20 #define GRPCPP_GENERIC_GENERIC_STUB_H
43 template <
class RequestType,
class ResponseType>
47 : channel_(channel) {}
53 std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
56 return CallInternal(channel_.get(), context, method, cq,
false,
nullptr);
66 return std::unique_ptr<ClientAsyncResponseReader<ResponseType>>(
67 internal::ClientAsyncResponseReaderHelper::Create<ResponseType>(
80 std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
Call(
83 return CallInternal(channel_.get(), context, method, cq,
true, tag);
86 #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
87 void UnaryCall(
ClientContext* context,
const std::string& method,
90 const RequestType* request, ResponseType* response,
92 UnaryCallInternal(context, method, request, response,
93 std::move(on_completion));
101 const RequestType* request, ResponseType* response,
103 PrepareUnaryCallInternal(context, method, request, response, reactor);
109 void PrepareBidiStreamingCall(
110 ClientContext* context,
const std::string& method,
111 ClientBidiReactor<RequestType, ResponseType>* reactor) {
112 PrepareBidiStreamingCallInternal(context, method, reactor);
126 const RequestType* request, ResponseType* response,
128 stub_->UnaryCallInternal(context, method, request, response,
129 std::move(on_completion));
137 const RequestType* request, ResponseType* response,
139 stub_->PrepareUnaryCallInternal(context, method, request, response,
149 stub_->PrepareBidiStreamingCallInternal(context, method, reactor);
162 std::shared_ptr<grpc::ChannelInterface> channel_;
164 void UnaryCallInternal(
ClientContext* context,
const std::string& method,
165 const RequestType* request, ResponseType* response,
171 context, request, response, std::move(on_completion));
174 void PrepareUnaryCallInternal(ClientContext* context,
175 const std::string& method,
176 const RequestType* request,
177 ResponseType* response,
179 internal::ClientCallbackUnaryFactory::Create<RequestType, ResponseType>(
183 context, request, response, reactor);
186 void PrepareBidiStreamingCallInternal(
187 ClientContext* context,
const std::string& method,
188 ClientBidiReactor<RequestType, ResponseType>* reactor) {
196 std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
199 bool start,
void* tag) {
200 return std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>(
206 context, start, tag));
214 #endif // GRPCPP_GENERIC_GENERIC_STUB_H
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
ClientUnaryReactor is a reactor-style interface for a unary RPC.
Definition: client_callback.h:431
TemplatedGenericStub(std::shared_ptr< grpc::ChannelInterface > channel)
Definition: generic_stub.h:46
ClientAsyncResponseReader< ByteBuffer > GenericClientAsyncResponseReader
Definition: generic_stub.h:38
void UnaryCall(ClientContext *context, const std::string &method, const RequestType *request, ResponseType *response, std::function< void(grpc::Status)> on_completion)
Setup and start a unary call to a named method method using context and specifying the request and re...
Definition: generic_stub.h:125
void PrepareBidiStreamingCall(ClientContext *context, const std::string &method, ClientBidiReactor< RequestType, ResponseType > *reactor)
Setup a call to a named method method using context and tied to reactor .
Definition: generic_stub.h:146
::grpc::ClientUnaryReactor ClientUnaryReactor
Definition: client_callback.h:1237
Did it work? If it didn't, why?
Definition: status.h:31
@ BIDI_STREAMING
Definition: rpc_method.h:35
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:192
static ClientAsyncReaderWriter< W, R > * Create(::grpc::ChannelInterface *channel, ::grpc::CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ::grpc::ClientContext *context, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:493
Async API for client-side unary RPCs, where the message response received from the server is of type ...
Definition: async_unary_call.h:35
ClientAsyncReaderWriter< ByteBuffer, ByteBuffer > GenericClientAsyncReaderWriter
Definition: generic_stub.h:34
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
void PrepareUnaryCall(ClientContext *context, const std::string &method, const RequestType *request, ResponseType *response, ClientUnaryReactor *reactor)
Setup a unary call to a named method method using context and specifying the request and response buf...
Definition: generic_stub.h:136
@ NORMAL_RPC
Definition: rpc_method.h:32
static void Create(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc::ClientContext *context, ClientBidiReactor< Request, Response > *reactor)
Definition: client_callback.h:700
std::unique_ptr< ClientAsyncReaderWriter< RequestType, ResponseType > > Call(ClientContext *context, const std::string &method, ::grpc::CompletionQueue *cq, void *tag)
DEPRECATED for multi-threaded use Begin a call to a named method method using context.
Definition: generic_stub.h:80
void CallbackUnaryCall(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc::ClientContext *context, const InputMessage *request, OutputMessage *result, std::function< void(::grpc::Status)> on_completion)
Perform a callback-based unary call.
Definition: client_callback.h:47
Generic stubs provide a type-unaware interface to call gRPC methods by name.
Definition: generic_stub.h:44
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: async_stream.h:511
NOTE: class experimental_type is not part of the public API of this class TODO(vjpai): Move these con...
Definition: generic_stub.h:119
std::unique_ptr< ClientAsyncReaderWriter< RequestType, ResponseType > > PrepareCall(ClientContext *context, const std::string &method, ::grpc::CompletionQueue *cq)
Setup a call to a named method method using context, but don't start it.
Definition: generic_stub.h:54
TemplatedGenericStub< grpc::ByteBuffer, grpc::ByteBuffer > GenericStub
Definition: generic_stub.h:210
experimental_type experimental()
NOTE: The function experimental() is not stable public API.
Definition: generic_stub.h:159
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:102
ClientBidiReactor is the interface for a bidirectional streaming RPC.
Definition: client_callback.h:136
Descriptor of an RPC method.
Definition: rpc_method.h:29
experimental_type(TemplatedGenericStub *stub)
Definition: generic_stub.h:121
std::unique_ptr< ClientAsyncResponseReader< ResponseType > > PrepareUnaryCall(ClientContext *context, const std::string &method, const RequestType &request, ::grpc::CompletionQueue *cq)
Setup a unary call to a named method method using context, and don't start it.
Definition: generic_stub.h:63