include/grpcpp/channel.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_CHANNEL_H
20 #define GRPCPP_CHANNEL_H
21 
22 #include <memory>
23 
24 #include <grpc/grpc.h>
25 #include <grpcpp/impl/call.h>
32 
33 struct grpc_channel;
34 
35 namespace grpc {
36 namespace testing {
37 class ChannelTestPeer;
38 } // namespace testing
39 
40 std::shared_ptr<Channel> CreateChannelInternal(
41  const std::string& host, grpc_channel* c_channel,
42  std::vector<
43  std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
44  interceptor_creators);
45 
46 namespace experimental {
51 } // namespace experimental
52 
54 class Channel final : public grpc::ChannelInterface,
56  public std::enable_shared_from_this<Channel>,
57  private grpc::GrpcLibraryCodegen {
58  public:
59  ~Channel() override;
60 
64 
67 
71 
72  private:
73  template <class InputMessage, class OutputMessage>
77  friend std::shared_ptr<Channel> grpc::CreateChannelInternal(
78  const std::string& host, grpc_channel* c_channel,
79  std::vector<std::unique_ptr<
81  interceptor_creators);
83  Channel(const std::string& host, grpc_channel* c_channel,
84  std::vector<std::unique_ptr<
86  interceptor_creators);
87 
90  grpc::CompletionQueue* cq) override;
92  grpc::internal::Call* call) override;
93  void* RegisterMethod(const char* method) override;
94 
97  void* tag) override;
99  gpr_timespec deadline) override;
100 
101  grpc::CompletionQueue* CallbackCQ() override;
102 
105  grpc::CompletionQueue* cq, size_t interceptor_pos) override;
106 
108  grpc_channel* const c_channel_; // owned
109 
110  // mu_ protects callback_cq_ (the per-channel callbackable completion queue)
112 
113  // callback_cq_ references the callbackable completion queue associated
114  // with this channel (if any). It is set on the first call to CallbackCQ().
115  // It is _not owned_ by the channel; ownership belongs with its internal
116  // shutdown callback tag (invoked when the CQ is fully shutdown).
117  std::atomic<CompletionQueue*> callback_cq_{nullptr};
118 
119  std::vector<
120  std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
122 };
123 
124 } // namespace grpc
125 
126 #endif // GRPCPP_CHANNEL_H
grpc::CreateChannelInternal
std::shared_ptr< Channel > CreateChannelInternal(const std::string &host, grpc_channel *c_channel, std::vector< std::unique_ptr< experimental::ClientInterceptorFactoryInterface >> interceptor_creators)
grpc::Channel::interceptor_creators_
std::vector< std::unique_ptr< grpc::experimental::ClientInterceptorFactoryInterface > > interceptor_creators_
Definition: include/grpcpp/channel.h:121
testing
Definition: aws_request_signer_test.cc:25
grpc::internal::CallHook
Definition: grpcpp/impl/codegen/call_hook.h:32
grpc::Channel::NotifyOnStateChangeImpl
void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, grpc::CompletionQueue *cq, void *tag) override
Definition: channel_cc.cc:202
grpc::Channel::PerformOpsOnCall
void PerformOpsOnCall(grpc::internal::CallOpSetInterface *ops, grpc::internal::Call *call) override
Definition: channel_cc.cc:169
grpc::experimental::ChannelResetConnectionBackoff
void ChannelResetConnectionBackoff(Channel *channel)
Definition: channel_cc.cc:111
grpc::internal::Mutex
Definition: include/grpcpp/impl/codegen/sync.h:59
grpc
Definition: grpcpp/alarm.h:33
grpc::internal::BlockingUnaryCallImpl
Definition: grpcpp/impl/codegen/channel_interface.h:69
grpc::Channel::callback_cq_
std::atomic< CompletionQueue * > callback_cq_
Definition: include/grpcpp/channel.h:117
grpc::internal::InterceptedChannel
Definition: intercepted_channel.h:37
grpc::internal::CallOpSetInterface
Definition: call_op_set_interface.h:36
grpc::experimental::ClientInterceptorFactoryInterface
Definition: impl/codegen/client_interceptor.h:48
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc::GrpcLibraryCodegen
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpcpp/impl/codegen/grpc_library.h:40
grpc::Channel
Channels represent a connection to an endpoint. Created by CreateChannel.
Definition: include/grpcpp/channel.h:54
config.h
grpc_connectivity_state
grpc_connectivity_state
Definition: include/grpc/impl/codegen/connectivity_state.h:30
call
FilterStackCall * call
Definition: call.cc:750
grpc::ChannelInterface
Codegen interface for grpc::Channel.
Definition: grpcpp/impl/codegen/channel_interface.h:73
channel
wrapped_grpc_channel * channel
Definition: src/php/ext/grpc/call.h:33
grpc::Channel::GetLoadBalancingPolicyName
std::string GetLoadBalancingPolicyName() const
Returns the LB policy name, or the empty string if not yet available.
Definition: channel_cc.cc:97
sync.h
grpc::Channel::GetState
grpc_connectivity_state GetState(bool try_to_connect) override
Definition: channel_cc.cc:180
grpc::internal::RpcMethod
Descriptor of an RPC method.
Definition: grpcpp/impl/codegen/rpc_method.h:31
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
grpc.h
completion_queue.h
grpc::Channel::c_channel_
grpc_channel *const c_channel_
Definition: include/grpcpp/channel.h:108
grpc::Channel::~Channel
~Channel() override
Definition: channel_cc.cc:63
grpc::testing::ChannelTestPeer
A test-only class to access private members of Channel.
Definition: channel_test_peer.h:28
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: include/grpcpp/impl/codegen/call.h:37
grpc::Channel::mu_
grpc::internal::Mutex mu_
Definition: include/grpcpp/channel.h:111
client_interceptor.h
grpc::ClientContext
Definition: grpcpp/impl/codegen/client_context.h:195
grpc_library.h
grpc::Channel::Channel
Channel(const std::string &host, grpc_channel *c_channel, std::vector< std::unique_ptr< grpc::experimental::ClientInterceptorFactoryInterface >> interceptor_creators)
Definition: channel_cc.cc:53
call.h
channel_interface.h
grpc::Channel::WaitForStateChangeImpl
bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) override
Definition: channel_cc.cc:210
grpc::Channel::RegisterMethod
void * RegisterMethod(const char *method) override
Definition: channel_cc.cc:175
grpc_channel
struct grpc_channel grpc_channel
Definition: grpc_types.h:62
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
grpc::Channel::GetServiceConfigJSON
std::string GetServiceConfigJSON() const
Definition: channel_cc.cc:103
grpc::Channel::CreateCallInternal
grpc::internal::Call CreateCallInternal(const grpc::internal::RpcMethod &method, grpc::ClientContext *context, grpc::CompletionQueue *cq, size_t interceptor_pos) override
Definition: channel_cc.cc:117
grpc::Channel::CreateCall
grpc::internal::Call CreateCall(const grpc::internal::RpcMethod &method, grpc::ClientContext *context, grpc::CompletionQueue *cq) override
Definition: channel_cc.cc:163
grpc::CompletionQueue
Definition: include/grpcpp/impl/codegen/completion_queue.h:104
gpr_timespec
Definition: gpr_types.h:50
tests.unit._exit_scenarios.try_to_connect
try_to_connect
Definition: _exit_scenarios.py:189
grpc::Channel::CallbackCQ
grpc::CompletionQueue * CallbackCQ() override
Definition: channel_cc.cc:249
method
NSString * method
Definition: ProtoMethod.h:28
ops
static grpc_op ops[6]
Definition: test/core/fling/client.cc:39
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37
grpc::Channel::host_
const std::string host_
Definition: include/grpcpp/channel.h:107


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:52