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

GH-44329: [C++][Flight] Add support for passing pointer options down to transports #44330

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct ARROW_FLIGHT_EXPORT FlightClientOptions {

/// \brief Generic connection options, passed to the underlying
/// transport; interpretation is implementation-dependent.
std::vector<std::pair<std::string, std::variant<int, std::string>>> generic_options;
std::vector<std::pair<std::string, std::variant<int, std::string, void*>>> generic_options;

/// \brief Use TLS without validating the server certificate. Use with caution.
bool disable_server_verification = false;
Expand Down
16 changes: 16 additions & 0 deletions cpp/src/arrow/flight/flight_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,22 @@ TEST_F(TestFlightClient, GenericOptions) {
ASSERT_THAT(status.message(), ::testing::HasSubstr("resource exhausted"));
}

TEST_F(TestFlightClient, GenericOptionsPointer) {
// WIP(bdm): I want to force GRPC to call my callback here so we can verify
// passing down the void* works. This isn't working yet.
bool callback_called = false;
auto callback = [&callback_called]() { callback_called = true; };

auto options = FlightClientOptions::Defaults();
// TODO(bdm): "some arbitrary function" probably needs to be changed to something
// GRPC will call
options.generic_options.emplace_back("some arbitrary function", reinterpret_cast<void*>(&callback));
ASSERT_OK_AND_ASSIGN(auto location, Location::ForGrpcTcp("localhost", server_->port()));
ASSERT_OK_AND_ASSIGN(auto client, FlightClient::Connect(location, options));

ASSERT_TRUE(callback_called);
}

TEST_F(TestFlightClient, TimeoutFires) {
// Server does not exist on this port, so call should fail
ASSERT_OK_AND_ASSIGN(auto location, Location::ForGrpcTcp("localhost", 30001));
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/flight/transport/grpc/grpc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,8 @@ class GrpcClientImpl : public internal::ClientTransport {
default_args[arg.first] = std::get<int>(arg.second);
} else if (std::holds_alternative<std::string>(arg.second)) {
args.SetString(arg.first, std::get<std::string>(arg.second));
} else if (std::holds_alternative<void*>(arg.second)) {
args.SetPointer(arg.first, std::get<void*>(arg.second));
}
// Otherwise unimplemented
}
Expand Down
Loading