Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method for creating insecure channel from FD with custom arguments using C++ API. #8046

Merged
merged 1 commit into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/grpc++/create_channel_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <memory>

#include <grpc++/channel.h>
#include <grpc++/support/channel_arguments.h>
#include <grpc/support/port_platform.h>

namespace grpc {
Expand All @@ -50,6 +51,15 @@ namespace grpc {
std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target,
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

} // namespace grpc
Expand Down
10 changes: 10 additions & 0 deletions src/cpp/client/create_channel_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target,
"", 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

} // namespace grpc