GRPC C++  1.62.0
delegating_channel.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2019 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_IMPL_DELEGATING_CHANNEL_H
20 #define GRPCPP_IMPL_DELEGATING_CHANNEL_H
21 
22 #include <memory>
23 
25 
26 namespace grpc {
27 namespace experimental {
28 
30  public:
31  ~DelegatingChannel() override {}
32 
34  std::shared_ptr<grpc::ChannelInterface> delegate_channel)
35  : delegate_channel_(delegate_channel) {}
36 
37  grpc_connectivity_state GetState(bool try_to_connect) override {
38  return delegate_channel()->GetState(try_to_connect);
39  }
40 
41  std::shared_ptr<grpc::ChannelInterface> delegate_channel() {
42  return delegate_channel_;
43  }
44 
45  private:
46  internal::Call CreateCall(const internal::RpcMethod& method,
47  ClientContext* context,
48  grpc::CompletionQueue* cq) final {
49  return delegate_channel()->CreateCall(method, context, cq);
50  }
51 
52  void PerformOpsOnCall(internal::CallOpSetInterface* ops,
53  internal::Call* call) final {
54  delegate_channel()->PerformOpsOnCall(ops, call);
55  }
56 
57  void* RegisterMethod(const char* method) final {
58  return delegate_channel()->RegisterMethod(method);
59  }
60 
61  void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
62  gpr_timespec deadline, grpc::CompletionQueue* cq,
63  void* tag) override {
64  delegate_channel()->NotifyOnStateChangeImpl(last_observed, deadline, cq,
65  tag);
66  }
67 
68  bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
69  gpr_timespec deadline) override {
70  return delegate_channel()->WaitForStateChangeImpl(last_observed, deadline);
71  }
72 
73  internal::Call CreateCallInternal(const internal::RpcMethod& method,
74  ClientContext* context,
76  size_t interceptor_pos) final {
77  return delegate_channel()->CreateCallInternal(method, context, cq,
78  interceptor_pos);
79  }
80 
81  grpc::CompletionQueue* CallbackCQ() final {
82  return delegate_channel()->CallbackCQ();
83  }
84 
85  std::shared_ptr<grpc::ChannelInterface> delegate_channel_;
86 };
87 
88 } // namespace experimental
89 } // namespace grpc
90 
91 #endif // GRPCPP_IMPL_DELEGATING_CHANNEL_H
grpc::experimental::DelegatingChannel::GetState
grpc_connectivity_state GetState(bool try_to_connect) override
Get the current channel state.
Definition: delegating_channel.h:37
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::experimental::DelegatingChannel::delegate_channel
std::shared_ptr< grpc::ChannelInterface > delegate_channel()
Definition: delegating_channel.h:41
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:36
grpc::experimental::DelegatingChannel::~DelegatingChannel
~DelegatingChannel() override
Definition: delegating_channel.h:31
grpc::experimental::DelegatingChannel::DelegatingChannel
DelegatingChannel(std::shared_ptr< grpc::ChannelInterface > delegate_channel)
Definition: delegating_channel.h:33
grpc::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:193
grpc_connectivity_state
grpc_connectivity_state
Connectivity state of a channel.
Definition: connectivity_state.h:30
grpc::internal::CallOpSetInterface
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call_op_set_interface.h:36
grpc::experimental::DelegatingChannel
Definition: delegating_channel.h:29
channel_interface.h
grpc::ChannelInterface
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
grpc::CompletionQueue
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:103
grpc::internal::RpcMethod
Descriptor of an RPC method.
Definition: rpc_method.h:29
gpr_timespec
Analogous to struct timespec.
Definition: time.h:48