GRPC C++  1.78.1
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_INTERCEPTED_CHANNEL_H
20 #define GRPCPP_IMPL_INTERCEPTED_CHANNEL_H
21 
23 
24 namespace grpc {
25 class CompletionQueue;
26 
27 namespace internal {
28 
29 class InterceptorBatchMethodsImpl;
30 
36  public:
37  ~InterceptedChannel() override { channel_ = nullptr; }
38 
41  grpc_connectivity_state GetState(bool try_to_connect) override {
42  return channel_->GetState(try_to_connect);
43  }
44 
46  const override {
47  return channel_->memory_allocator();
48  }
49 
50  private:
51  InterceptedChannel(ChannelInterface* channel, size_t pos)
52  : channel_(channel), interceptor_pos_(pos) {}
53 
54  Call CreateCall(const RpcMethod& method, grpc::ClientContext* context,
55  grpc::CompletionQueue* cq) override {
56  return channel_->CreateCallInternal(method, context, cq, interceptor_pos_);
57  }
58 
59  void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override {
60  return channel_->PerformOpsOnCall(ops, call);
61  }
62  void* RegisterMethod(const char* method) override {
63  return channel_->RegisterMethod(method);
64  }
65 
66  void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
67  gpr_timespec deadline, grpc::CompletionQueue* cq,
68  void* tag) override {
69  return channel_->NotifyOnStateChangeImpl(last_observed, deadline, cq, tag);
70  }
71  bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
72  gpr_timespec deadline) override {
73  return channel_->WaitForStateChangeImpl(last_observed, deadline);
74  }
75 
76  grpc::CompletionQueue* CallbackCQ() override {
77  return channel_->CallbackCQ();
78  }
79 
80  ChannelInterface* channel_;
81  size_t interceptor_pos_;
82 
84 };
85 } // namespace internal
86 } // namespace grpc
87 
88 #endif // GRPCPP_IMPL_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:41
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:194
grpc_connectivity_state
grpc_connectivity_state
Connectivity state of a channel.
Definition: connectivity_state.h:30
channel_interface.h
grpc::ChannelInterface
Codegen interface for grpc::Channel.
Definition: channel_interface.h:72
grpc::internal::InterceptedChannel
An InterceptedChannel is available to client Interceptors.
Definition: intercepted_channel.h:35
grpc::ChannelInterface::GetState
virtual grpc_connectivity_state GetState(bool try_to_connect)=0
Get the current channel state.
grpc::internal::InterceptedChannel::~InterceptedChannel
~InterceptedChannel() override
Definition: intercepted_channel.h:37
grpc::CompletionQueue
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:104
grpc_event_engine::experimental::MemoryAllocator
Definition: memory_allocator.h:33
grpc::internal::InterceptedChannel::memory_allocator
grpc_event_engine::experimental::MemoryAllocator * memory_allocator() const override
Definition: intercepted_channel.h:45
gpr_timespec
Analogous to struct timespec.
Definition: time.h:47
grpc::internal::InterceptorBatchMethodsImpl
Definition: interceptor_common.h:37
grpc::ChannelInterface::memory_allocator
virtual grpc_event_engine::experimental::MemoryAllocator * memory_allocator() const
Definition: channel_interface.h:106