Go to the documentation of this file.
19 #ifndef GRPCPP_GENERIC_GENERIC_STUB_H
20 #define GRPCPP_GENERIC_GENERIC_STUB_H
44 template <
class RequestType,
class ResponseType>
48 : channel_(channel) {}
54 std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
57 return CallInternal(channel_.get(), context, method, {}, cq,
68 return std::unique_ptr<ClientAsyncResponseReader<ResponseType>>(
69 internal::ClientAsyncResponseReaderHelper::Create<ResponseType>(
83 std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
Call(
86 return CallInternal(channel_.get(), context, method, {}, cq,
94 ResponseType* response,
96 UnaryCallInternal(context, method, options, request, response,
97 std::move(on_completion));
107 PrepareUnaryCallInternal(context, method, options, request, response,
117 PrepareBidiStreamingCallInternal(context, method, options, reactor);
121 std::shared_ptr<grpc::ChannelInterface> channel_;
123 void UnaryCallInternal(
ClientContext* context,
const std::string& method,
125 ResponseType* response,
131 context, request, response, std::move(on_completion));
134 void PrepareUnaryCallInternal(ClientContext* context,
135 const std::string& method, StubOptions options,
136 const RequestType* request,
137 ResponseType* response,
138 ClientUnaryReactor* reactor) {
139 internal::ClientCallbackUnaryFactory::Create<RequestType, ResponseType>(
143 context, request, response, reactor);
146 void PrepareBidiStreamingCallInternal(
147 ClientContext* context,
const std::string& method, StubOptions options,
148 ClientBidiReactor<RequestType, ResponseType>* reactor) {
152 method.c_str(), options.suffix_for_stats(),
157 std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
159 const std::string& method, StubOptions options,
161 return std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>(
165 method.c_str(), options.suffix_for_stats(),
167 context, start, tag));
175 #endif // GRPCPP_GENERIC_GENERIC_STUB_H
void UnaryCall(ClientContext *context, const std::string &method, StubOptions options, 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:92
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
static void Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, ClientBidiReactor< Request, Response > *reactor)
Definition: client_callback.h:702
const char * suffix_for_stats() const
Definition: stub_options.h:34
TemplatedGenericStub(std::shared_ptr< grpc::ChannelInterface > channel)
Definition: generic_stub.h:47
ClientAsyncResponseReader< ByteBuffer > GenericClientAsyncResponseReader
Definition: generic_stub.h:39
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:51
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:495
Useful interface for generated stubs.
Definition: stub_options.h:25
void PrepareBidiStreamingCall(ClientContext *context, const std::string &method, StubOptions options, ClientBidiReactor< RequestType, ResponseType > *reactor)
Setup a call to a named method method using context and tied to reactor .
Definition: generic_stub.h:114
Did it work? If it didn't, why?
Definition: status.h:35
@ BIDI_STREAMING
Definition: rpc_method.h:35
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:193
Async API for client-side unary RPCs, where the message response received from the server is of type ...
Definition: client_context.h:91
ClientAsyncReaderWriter< ByteBuffer, ByteBuffer > GenericClientAsyncReaderWriter
Definition: generic_stub.h:35
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
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:55
void PrepareUnaryCall(ClientContext *context, const std::string &method, StubOptions options, 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:104
@ NORMAL_RPC
Definition: rpc_method.h:32
Generic stubs provide a type-unaware interface to call gRPC methods by name.
Definition: generic_stub.h:45
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: client_context.h:89
TemplatedGenericStub< grpc::ByteBuffer, grpc::ByteBuffer > GenericStub
Definition: generic_stub.h:171
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:103
ClientBidiReactor is the interface for a bidirectional streaming RPC.
Definition: client_callback.h:141
Descriptor of an RPC method.
Definition: rpc_method.h:29
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:83
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:65