GRPC C++  1.17.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 
27 #include <grpcpp/support/status.h>
28 
29 namespace grpc {
30 
35 
38 class GenericStub final {
39  public:
40  explicit GenericStub(std::shared_ptr<ChannelInterface> channel)
41  : channel_(channel) {}
42 
47  std::unique_ptr<GenericClientAsyncReaderWriter> PrepareCall(
48  ClientContext* context, const grpc::string& method, CompletionQueue* cq);
49 
54  std::unique_ptr<GenericClientAsyncResponseReader> PrepareUnaryCall(
55  ClientContext* context, const grpc::string& method,
56  const ByteBuffer& request, CompletionQueue* cq);
57 
64  std::unique_ptr<GenericClientAsyncReaderWriter> Call(
65  ClientContext* context, const grpc::string& method, CompletionQueue* cq,
66  void* tag);
67 
72  public:
73  explicit experimental_type(GenericStub* stub) : stub_(stub) {}
74 
75  void UnaryCall(ClientContext* context, const grpc::string& method,
76  const ByteBuffer* request, ByteBuffer* response,
77  std::function<void(Status)> on_completion);
78 
79  private:
80  GenericStub* stub_;
81  };
82 
87 
88  private:
89  std::shared_ptr<ChannelInterface> channel_;
90 };
91 
92 } // namespace grpc
93 
94 #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:73
NOTE: class experimental_type is not part of the public API of this class TODO(vjpai): Move these con...
Definition: generic_stub.h:71
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:165
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.
ClientAsyncResponseReader< ByteBuffer > GenericClientAsyncResponseReader
Definition: generic_stub.h:34
An Alarm posts the user provided tag to its associated completion queue upon expiry or cancellation...
Definition: alarm.h:33
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:86
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:31
Generic stubs provide a type-unsafe interface to call gRPC methods by name.
Definition: generic_stub.h:38
GenericStub(std::shared_ptr< ChannelInterface > channel)
Definition: generic_stub.h:40
A sequence of bytes.
Definition: byte_buffer.h:62
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.