GRPC C++  1.39.1
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_CODEGEN_DELEGATING_CHANNEL_H
20 #define GRPCPP_IMPL_CODEGEN_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,
64  void* tag) override {
65  delegate_channel()->NotifyOnStateChangeImpl(last_observed, deadline, cq,
66  tag);
67  }
68 
69  bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
70  gpr_timespec deadline) override {
71  return delegate_channel()->WaitForStateChangeImpl(last_observed, deadline);
72  }
73 
74  internal::Call CreateCallInternal(const internal::RpcMethod& method,
75  ClientContext* context,
77  size_t interceptor_pos) final {
78  return delegate_channel()->CreateCallInternal(method, context, cq,
79  interceptor_pos);
80  }
81 
82  ::grpc::CompletionQueue* CallbackCQ() final {
83  return delegate_channel()->CallbackCQ();
84  }
85 
86  std::shared_ptr<::grpc::ChannelInterface> delegate_channel_;
87 };
88 
89 } // namespace experimental
90 } // namespace grpc
91 
92 #endif // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:193
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:102
Definition: delegating_channel.h:29
~DelegatingChannel() override
Definition: delegating_channel.h:31
std::shared_ptr<::grpc::ChannelInterface > delegate_channel()
Definition: delegating_channel.h:41
grpc_connectivity_state GetState(bool try_to_connect) override
Get the current channel state.
Definition: delegating_channel.h:37
DelegatingChannel(std::shared_ptr<::grpc::ChannelInterface > delegate_channel)
Definition: delegating_channel.h:33
Straightforward wrapping of the C call object.
Definition: call.h:35
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:34
Descriptor of an RPC method.
Definition: rpc_method.h:29
grpc_connectivity_state
Connectivity state of a channel.
Definition: connectivity_state.h:27
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
Analogous to struct timespec.
Definition: gpr_types.h:47