create_channel_posix.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 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 #include <memory>
20 #include <string>
21 #include <utility>
22 #include <vector>
23 
24 #include <grpc/grpc.h>
25 #include <grpc/grpc_posix.h>
26 #include <grpc/grpc_security.h>
28 #include <grpcpp/channel.h>
32 #include <grpcpp/support/config.h>
33 
35 
36 namespace grpc {
37 
38 class ChannelArguments;
39 
40 #ifdef GPR_SUPPORT_CHANNELS_FROM_FD
41 
42 std::shared_ptr<Channel> CreateInsecureChannelFromFd(const std::string& target,
43  int fd) {
44  internal::GrpcLibrary init_lib;
45  init_lib.init();
48  "", grpc_channel_create_from_fd(target.c_str(), fd, creds, nullptr),
49  std::vector<
50  std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>());
52  // Channel also initializes gRPC, so we can decrement the init ref count here.
53  init_lib.shutdown();
54  return channel;
55 }
56 
57 std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
58  const std::string& target, int fd, const grpc::ChannelArguments& args) {
59  internal::GrpcLibrary init_lib;
60  init_lib.init();
61  grpc_channel_args channel_args;
62  args.SetChannelArgs(&channel_args);
65  "", grpc_channel_create_from_fd(target.c_str(), fd, creds, &channel_args),
66  std::vector<
67  std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>());
69  // Channel also initializes gRPC, so we can decrement the init ref count here.
70  init_lib.shutdown();
71  return channel;
72 }
73 
74 namespace experimental {
75 
76 std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd(
77  const std::string& target, int fd, const ChannelArguments& args,
78  std::vector<
79  std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
80  interceptor_creators) {
81  internal::GrpcLibrary init_lib;
82  init_lib.init();
83  grpc_channel_args channel_args;
84  args.SetChannelArgs(&channel_args);
87  "", grpc_channel_create_from_fd(target.c_str(), fd, creds, &channel_args),
88  std::move(interceptor_creators));
90  // Channel also initializes gRPC, so we can decrement the init ref count here.
91  init_lib.shutdown();
92  return channel;
93 }
94 
95 } // namespace experimental
96 
97 #endif // GPR_SUPPORT_CHANNELS_FROM_FD
98 
99 } // namespace grpc
grpc::CreateChannelInternal
std::shared_ptr< Channel > CreateChannelInternal(const std::string &host, grpc_channel *c_channel, std::vector< std::unique_ptr< experimental::ClientInterceptorFactoryInterface >> interceptor_creators)
create_channel_internal.h
grpc
Definition: grpcpp/alarm.h:33
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_security.h
grpc_channel_args
Definition: grpc_types.h:132
grpc_types.h
client_interceptor.h
channel
wrapped_grpc_channel * channel
Definition: src/php/ext/grpc/call.h:33
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
channel_arguments.h
grpc.h
grpc_insecure_credentials_create
GRPCAPI grpc_channel_credentials * grpc_insecure_credentials_create()
Definition: core/lib/security/credentials/insecure/insecure_credentials.cc:64
channel.h
grpc_posix.h
config.h
grpc_channel_credentials_release
GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials *creds)
Definition: credentials.cc:36
grpc::ChannelArguments
Definition: grpcpp/support/channel_arguments.h:39
grpc_channel_create_from_fd
GRPCAPI grpc_channel * grpc_channel_create_from_fd(const char *target, int fd, grpc_channel_credentials *creds, const grpc_channel_args *args)
Definition: chttp2_connector.cc:453
grpc_library.h
setup.target
target
Definition: third_party/bloaty/third_party/protobuf/python/setup.py:179
grpc_channel_credentials
Definition: src/core/lib/security/credentials/credentials.h:96


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:06