GRPC C++  1.18.0
generic_stub.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_H
20 #define GRPCPP_GENERIC_GENERIC_STUB_H
21 
22 #include <functional>
23 
28 #include <grpcpp/support/status.h>
29 
30 namespace grpc {
31 
36 
39 class GenericStub final {
40  public:
41  explicit GenericStub(std::shared_ptr<ChannelInterface> channel)
42  : channel_(channel) {}
43 
48  std::unique_ptr<GenericClientAsyncReaderWriter> PrepareCall(
49  ClientContext* context, const grpc::string& method, CompletionQueue* cq);
50 
55  std::unique_ptr<GenericClientAsyncResponseReader> PrepareUnaryCall(
56  ClientContext* context, const grpc::string& method,
57  const ByteBuffer& request, CompletionQueue* cq);
58 
65  std::unique_ptr<GenericClientAsyncReaderWriter> Call(
66  ClientContext* context, const grpc::string& method, CompletionQueue* cq,
67  void* tag);
68 
73  public:
74  explicit experimental_type(GenericStub* stub) : stub_(stub) {}
75 
76  void UnaryCall(ClientContext* context, const grpc::string& method,
77  const ByteBuffer* request, ByteBuffer* response,
78  std::function<void(Status)> on_completion);
79 
81  ClientContext* context, const grpc::string& method,
83 
84  private:
85  GenericStub* stub_;
86  };
87 
92 
93  private:
94  std::shared_ptr<ChannelInterface> channel_;
95 };
96 
97 } // namespace grpc
98 
99 #endif // GRPCPP_GENERIC_GENERIC_STUB_H
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: async_stream.h:514
std::string string
Definition: config.h:35
std::unique_ptr< GenericClientAsyncResponseReader > PrepareUnaryCall(ClientContext *context, const grpc::string &method, const ByteBuffer &request, CompletionQueue *cq)
Setup a unary call to a named method method using context, and don&#39;t start it.
experimental_type(GenericStub *stub)
Definition: generic_stub.h:74
NOTE: class experimental_type is not part of the public API of this class TODO(vjpai): Move these con...
Definition: generic_stub.h:72
Async API for client-side unary RPCs, where the message response received from the server is of type ...
Definition: async_unary_call.h:98
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:174
std::unique_ptr< GenericClientAsyncReaderWriter > Call(ClientContext *context, const grpc::string &method, CompletionQueue *cq, void *tag)
DEPRECATED for multi-threaded use Begin a call to a named method method using context.
void PrepareBidiStreamingCall(ClientContext *context, const grpc::string &method, experimental::ClientBidiReactor< ByteBuffer, ByteBuffer > *reactor)
ClientAsyncResponseReader< ByteBuffer > GenericClientAsyncResponseReader
Definition: generic_stub.h:35
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
Definition: client_callback.h:98
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:95
experimental_type experimental()
NOTE: The function experimental() is not stable public API.
Definition: generic_stub.h:91
void UnaryCall(ClientContext *context, const grpc::string &method, const ByteBuffer *request, ByteBuffer *response, std::function< void(Status)> on_completion)
Did it work? If it didn&#39;t, why?
Definition: status.h:31
ClientAsyncReaderWriter< ByteBuffer, ByteBuffer > GenericClientAsyncReaderWriter
Definition: generic_stub.h:32
Generic stubs provide a type-unsafe interface to call gRPC methods by name.
Definition: generic_stub.h:39
GenericStub(std::shared_ptr< ChannelInterface > channel)
Definition: generic_stub.h:41
A sequence of bytes.
Definition: byte_buffer.h:64
std::unique_ptr< GenericClientAsyncReaderWriter > PrepareCall(ClientContext *context, const grpc::string &method, CompletionQueue *cq)
Setup a call to a named method method using context, but don&#39;t start it.