wjones127 commented on code in PR #15118:
URL: https://github.com/apache/arrow/pull/15118#discussion_r1059529100


##########
cpp/src/arrow/flight/transport/grpc/grpc_client.cc:
##########
@@ -499,6 +499,65 @@ constexpr char kDummyRootCert[] =
     "-----END CERTIFICATE-----\n";
 #endif
 
+class GrpcResultStream : public ResultStream {
+ public:
+  explicit GrpcResultStream(const FlightCallOptions& options)
+      : rpc_(options),
+        stop_token_(options.stop_token),
+        status_(
+            Status::UnknownError("Internal implementation error, stream not 
started")) {}
+
+  ~GrpcResultStream() override {
+    if (stream_) {
+      rpc_.context.TryCancel();
+      ARROW_WARN_NOT_OK(FromGrpcStatus(stream_->Finish(), &rpc_.context),
+                        "DoAction result was not fully consumed");
+    }
+  }
+
+  static arrow::Result<std::unique_ptr<GrpcResultStream>> Make(
+      const FlightCallOptions& options, pb::FlightService::Stub* stub,
+      ClientAuthHandler* auth_handler, const Action& action) {
+    auto result = std::make_unique<GrpcResultStream>(options);
+    ARROW_RETURN_NOT_OK(result->Init(stub, auth_handler, action));
+    return result;
+  }
+
+  Status Init(pb::FlightService::Stub* stub, ClientAuthHandler* auth_handler,
+              const Action& action) {
+    pb::Action pb_action;
+    RETURN_NOT_OK(internal::ToProto(action, &pb_action));
+    RETURN_NOT_OK(rpc_.SetToken(auth_handler));
+    stream_ = stub->DoAction(&rpc_.context, pb_action);
+    return Status::OK();
+  }
+
+  arrow::Result<std::unique_ptr<Result>> Next() override {
+    if (stream_) {
+      pb::Result pb_result;
+      if (!stop_token_.IsStopRequested() && stream_->Read(&pb_result)) {
+        auto result = std::make_unique<Result>();
+        RETURN_NOT_OK(internal::FromProto(pb_result, result.get()));
+        return result;
+      } else if (stop_token_.IsStopRequested()) {
+        rpc_.context.TryCancel();
+      }
+      RETURN_NOT_OK(stop_token_.Poll());
+
+      status_ = FromGrpcStatus(stream_->Finish(), &rpc_.context);
+      stream_.reset();
+    }
+    RETURN_NOT_OK(status_);
+    return nullptr;
+  }
+
+  // private:

Review Comment:
   Uncomment?



##########
cpp/src/arrow/flight/flight_test.cc:
##########
@@ -1286,11 +1289,12 @@ TEST_F(TestTls, OverrideHostname) {
   ASSERT_OK_AND_ASSIGN(auto client, FlightClient::Connect(location_, 
client_options));
 
   FlightCallOptions options;
-  options.timeout = TimeoutDuration{5.0};
+  // options.timeout = TimeoutDuration{5.0};

Review Comment:
   Should this be removed? Or kept?



-- 
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