GRPC C++  1.26.0
generic_stub_impl.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPCPP_GENERIC_GENERIC_STUB_IMPL_H
20 #define GRPCPP_GENERIC_GENERIC_STUB_IMPL_H
21 
22 #include <functional>
23 
24 #include <grpcpp/client_context.h>
29 #include <grpcpp/support/status.h>
30 
31 namespace grpc {
32 
33 typedef ::grpc_impl::ClientAsyncReaderWriter<ByteBuffer, ByteBuffer>
35 typedef ::grpc_impl::ClientAsyncResponseReader<ByteBuffer>
37 } // namespace grpc
38 namespace grpc_impl {
39 class CompletionQueue;
40 
43 class GenericStub final {
44  public:
45  explicit GenericStub(std::shared_ptr<grpc::ChannelInterface> channel)
46  : channel_(channel) {}
47 
52  std::unique_ptr<grpc::GenericClientAsyncReaderWriter> PrepareCall(
53  grpc::ClientContext* context, const grpc::string& method,
54  CompletionQueue* cq);
55 
60  std::unique_ptr<grpc::GenericClientAsyncResponseReader> PrepareUnaryCall(
61  grpc_impl::ClientContext* context, const grpc::string& method,
62  const grpc::ByteBuffer& request, CompletionQueue* cq);
63 
70  std::unique_ptr<grpc::GenericClientAsyncReaderWriter> Call(
71  grpc_impl::ClientContext* context, const grpc::string& method,
72  CompletionQueue* cq, void* tag);
73 
78  public:
79  explicit experimental_type(GenericStub* stub) : stub_(stub) {}
80 
83  void UnaryCall(grpc_impl::ClientContext* context,
84  const grpc::string& method, const grpc::ByteBuffer* request,
85  grpc::ByteBuffer* response,
86  std::function<void(grpc::Status)> on_completion);
87 
90  void UnaryCall(grpc_impl::ClientContext* context,
91  const grpc::string& method, const grpc::ByteBuffer* request,
92  grpc::ByteBuffer* response,
94 
98  void PrepareBidiStreamingCall(
99  grpc_impl::ClientContext* context, const grpc::string& method,
101  reactor);
102 
103  private:
104  GenericStub* stub_;
105  };
106 
111 
112  private:
113  std::shared_ptr<grpc::ChannelInterface> channel_;
114 };
115 
116 } // namespace grpc_impl
117 
118 #endif // GRPCPP_GENERIC_GENERIC_STUB_IMPL_H
std::string string
Definition: config.h:35
NOTE: class experimental_type is not part of the public API of this class TODO(vjpai): Move these con...
Definition: generic_stub_impl.h:77
GenericStub(std::shared_ptr< grpc::ChannelInterface > channel)
Definition: generic_stub_impl.h:45
ClientUnaryReactor is a reactor-style interface for a unary RPC.
Definition: client_callback_impl.h:386
Generic stubs provide a type-unsafe interface to call gRPC methods by name.
Definition: generic_stub_impl.h:43
::grpc_impl::ClientAsyncReaderWriter< ByteBuffer, ByteBuffer > GenericClientAsyncReaderWriter
Definition: generic_stub_impl.h:34
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
experimental_type(GenericStub *stub)
Definition: generic_stub_impl.h:79
ClientBidiReactor is the interface for a bidirectional streaming RPC.
Definition: client_callback_impl.h:108
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
experimental_type experimental()
NOTE: The function experimental() is not stable public API.
Definition: generic_stub_impl.h:110
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue_impl.h:100
A ClientContext allows the person implementing a service client to:
Definition: client_context_impl.h:184
Did it work? If it didn&#39;t, why?
Definition: status.h:31
::grpc_impl::ClientAsyncResponseReader< ByteBuffer > GenericClientAsyncResponseReader
Definition: generic_stub_impl.h:36
A sequence of bytes.
Definition: byte_buffer.h:67