GRPC C++  1.30.0
intercepted_channel.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 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_INTERCEPTED_CHANNEL_H
20 #define GRPCPP_IMPL_CODEGEN_INTERCEPTED_CHANNEL_H
21 
23 
24 namespace grpc_impl {
25 class CompletionQueue;
26 }
27 
28 namespace grpc {
29 
30 namespace internal {
31 
32 class InterceptorBatchMethodsImpl;
33 
39  public:
40  virtual ~InterceptedChannel() { channel_ = nullptr; }
41 
44  grpc_connectivity_state GetState(bool try_to_connect) override {
45  return channel_->GetState(try_to_connect);
46  }
47 
48  private:
49  InterceptedChannel(ChannelInterface* channel, size_t pos)
50  : channel_(channel), interceptor_pos_(pos) {}
51 
52  Call CreateCall(const RpcMethod& method, ::grpc_impl::ClientContext* context,
53  ::grpc_impl::CompletionQueue* cq) override {
54  return channel_->CreateCallInternal(method, context, cq, interceptor_pos_);
55  }
56 
57  void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override {
58  return channel_->PerformOpsOnCall(ops, call);
59  }
60  void* RegisterMethod(const char* method) override {
61  return channel_->RegisterMethod(method);
62  }
63 
64  void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
65  gpr_timespec deadline,
67  void* tag) override {
68  return channel_->NotifyOnStateChangeImpl(last_observed, deadline, cq, tag);
69  }
70  bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
71  gpr_timespec deadline) override {
72  return channel_->WaitForStateChangeImpl(last_observed, deadline);
73  }
74 
75  ::grpc_impl::CompletionQueue* CallbackCQ() override {
76  return channel_->CallbackCQ();
77  }
78 
79  ChannelInterface* channel_;
80  size_t interceptor_pos_;
81 
83 };
84 } // namespace internal
85 } // namespace grpc
86 
87 #endif // GRPCPP_IMPL_CODEGEN_INTERCEPTED_CHANNEL_H
grpc::internal::InterceptedChannel::GetState
grpc_connectivity_state GetState(bool try_to_connect) override
Get the current channel state.
Definition: intercepted_channel.h:44
grpc
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
grpc::CompletionQueue
::grpc_impl::CompletionQueue CompletionQueue
Definition: completion_queue.h:26
grpc_connectivity_state
grpc_connectivity_state
Connectivity state of a channel.
Definition: connectivity_state.h:27
grpc::ChannelInterface
Codegen interface for grpc::Channel.
Definition: channel_interface.h:74
grpc::internal::InterceptedChannel
An InterceptedChannel is available to client Interceptors.
Definition: intercepted_channel.h:38
grpc_impl::CompletionQueue
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue_impl.h:103
channel_interface.h
grpc::ChannelInterface::GetState
virtual grpc_connectivity_state GetState(bool try_to_connect)=0
Get the current channel state.
grpc::internal::InterceptedChannel::~InterceptedChannel
virtual ~InterceptedChannel()
Definition: intercepted_channel.h:40
grpc_impl
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
grpc_impl::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context_impl.h:184
gpr_timespec
Analogous to struct timespec.
Definition: gpr_types.h:47
grpc::internal::InterceptorBatchMethodsImpl
Definition: interceptor_common.h:36