Skip to content
Snippets Groups Projects
Commit dbdc6e4a authored by Adam Czachorowski's avatar Adam Czachorowski
Browse files

Add method for creating insecure channel from FD with custom arguments

using C++ API.

This was already supported in C API.
parent 93b09478
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <memory> #include <memory>
#include <grpc++/channel.h> #include <grpc++/channel.h>
#include <grpc++/support/channel_arguments.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
namespace grpc { namespace grpc {
...@@ -50,6 +51,15 @@ namespace grpc { ...@@ -50,6 +51,15 @@ namespace grpc {
std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target, std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target,
int fd); int fd);
/// Create a new \a Channel communicating over given file descriptor with custom
/// channel arguments
///
/// \param target The name of the target.
/// \param fd The file descriptor representing a socket.
/// \param args Options for channel creation.
std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
const grpc::string& target, int fd, const ChannelArguments& args);
#endif // GPR_SUPPORT_CHANNELS_FROM_FD #endif // GPR_SUPPORT_CHANNELS_FROM_FD
} // namespace grpc } // namespace grpc
......
...@@ -51,6 +51,16 @@ std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target, ...@@ -51,6 +51,16 @@ std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target,
"", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr)); "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr));
} }
std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
const grpc::string& target, int fd, const ChannelArguments& args) {
internal::GrpcLibrary init_lib;
init_lib.init();
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
return CreateChannelInternal("", grpc_insecure_channel_create_from_fd(
target.c_str(), fd, &channel_args));
}
#endif // GPR_SUPPORT_CHANNELS_FROM_FD #endif // GPR_SUPPORT_CHANNELS_FROM_FD
} // namespace grpc } // namespace grpc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment