wjones127 commented on a change in pull request #153:
URL: https://github.com/apache/arrow-cookbook/pull/153#discussion_r814355218



##########
File path: cpp/code/flight.cc
##########
@@ -291,4 +307,99 @@ arrow::Status TestPutGetDelete() {
   return arrow::Status::OK();
 }
 
+arrow::Status TestClientOptions() {
+  // Set up server as usual
+  auto fs = std::make_shared<arrow::fs::LocalFileSystem>();
+  ARROW_RETURN_NOT_OK(fs->CreateDir("./flight_datasets/"));
+  ARROW_RETURN_NOT_OK(fs->DeleteDirContents("./flight_datasets/"));
+  auto root = 
std::make_shared<arrow::fs::SubTreeFileSystem>("./flight_datasets/", fs);
+
+  arrow::flight::Location server_location;
+  ARROW_RETURN_NOT_OK(
+      arrow::flight::Location::ForGrpcTcp("0.0.0.0", 0, &server_location));
+
+  arrow::flight::FlightServerOptions options(server_location);
+  auto server = std::unique_ptr<arrow::flight::FlightServerBase>(
+      new ParquetStorageService(std::move(root)));
+  ARROW_RETURN_NOT_OK(server->Init(options));
+
+  StartRecipe("TestClientOptions::Connect");
+  auto client_options = arrow::flight::FlightClientOptions::Defaults();
+  // Set a very low limit at the gRPC layer to fail all calls
+  
client_options.generic_options.emplace_back(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, 
2);
+
+  arrow::flight::Location location;
+  ARROW_RETURN_NOT_OK(
+      arrow::flight::Location::ForGrpcTcp("localhost", server->port(), 
&location));
+
+  std::unique_ptr<arrow::flight::FlightClient> client;
+  ARROW_RETURN_NOT_OK(  // pass client_options into Connect()
+      arrow::flight::FlightClient::Connect(location, client_options, &client));
+  rout << "Connected to " << location.ToString() << std::endl;
+  EndRecipe("TestClientOptions::Connect");
+
+  auto descriptor = 
arrow::flight::FlightDescriptor::Path({"airquality.parquet"});
+  std::unique_ptr<arrow::flight::FlightInfo> flight_info;
+  return client->GetFlightInfo(descriptor, &flight_info);
+}
+
+arrow::Status TestCustomGrpcImpl() {
+  StartRecipe("CustomGrpcImpl::StartServer");
+  // Build flight service as usual
+  auto fs = std::make_shared<arrow::fs::LocalFileSystem>();
+  ARROW_RETURN_NOT_OK(fs->CreateDir("./flight_datasets/"));
+  ARROW_RETURN_NOT_OK(fs->DeleteDirContents("./flight_datasets/"));
+  auto root = 
std::make_shared<arrow::fs::SubTreeFileSystem>("./flight_datasets/", fs);
+
+  arrow::flight::Location server_location;
+  ARROW_RETURN_NOT_OK(
+      arrow::flight::Location::ForGrpcTcp("0.0.0.0", 3000, &server_location));
+
+  arrow::flight::FlightServerOptions options(server_location);
+  auto server = std::unique_ptr<arrow::flight::FlightServerBase>(
+      new ParquetStorageService(std::move(root)));
+
+  // Create hello world service
+  HelloWorldServiceImpl grpc_service;
+  // Both services will be available on both ports
+  int hello_world_port;
+
+  options.builder_hook = [&](void* raw_builder) {
+    auto* builder = reinterpret_cast<grpc::ServerBuilder*>(raw_builder);
+    builder->AddListeningPort("0.0.0.0:5000", 
grpc::InsecureServerCredentials(),
+                              &hello_world_port);

Review comment:
       Yeah I cut that out and also cut off the first part the recipe snippet 
that is repetitive.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to