kou commented on code in PR #36517: URL: https://github.com/apache/arrow/pull/36517#discussion_r1263184907
########## cpp/src/arrow/flight/client.cc: ########## @@ -620,6 +621,17 @@ Status FlightClient::GetFlightInfo(const FlightCallOptions& options, return GetFlightInfo(options, descriptor).Value(info); } +void FlightClient::GetFlightInfo(const FlightCallOptions& options, + const FlightDescriptor& descriptor, + std::shared_ptr<AsyncListener<FlightInfo>> listener) { + if (auto status = CheckOpen(); !status.ok()) { + listener->OnFinish( + TransportStatus{TransportStatusCode::kInternal, status.ToString()}); Review Comment: It may be better that we don't export `TransportStatus` to users because we have many useful macros for `arrow::Status` such as `ARROW_RETURN_NOT_OK()`. Can we use `arrow::Status` directly? It seems that `TransportStatus` may have `arrow::Status` via `ArrowStatusDetail`. Can we put `TransportStatus` into `arrow::Status::detail()` by creating `TransportStatusDetail` or something? ########## cpp/src/arrow/flight/types.cc: ########## @@ -951,5 +954,250 @@ arrow::Result<std::string> BasicAuth::SerializeToString() const { Status BasicAuth::Serialize(const BasicAuth& basic_auth, std::string* out) { return basic_auth.SerializeToString().Value(out); } + +//------------------------------------------------------------ +// Error propagation helpers + +std::string ToString(TransportStatusCode code) { + switch (code) { + case TransportStatusCode::kOk: + return "kOk"; + case TransportStatusCode::kUnknown: + return "kUnknown"; + case TransportStatusCode::kInternal: + return "kInternal"; + case TransportStatusCode::kInvalidArgument: + return "kInvalidArgument"; + case TransportStatusCode::kTimedOut: + return "kTimedOut"; + case TransportStatusCode::kNotFound: + return "kNotFound"; + case TransportStatusCode::kAlreadyExists: + return "kAlreadyExists"; + case TransportStatusCode::kCancelled: + return "kCancelled"; + case TransportStatusCode::kUnauthenticated: + return "kUnauthenticated"; + case TransportStatusCode::kUnauthorized: + return "kUnauthorized"; + case TransportStatusCode::kUnimplemented: + return "kUnimplemented"; + case TransportStatusCode::kUnavailable: + return "kUnavailable"; + } + return "(unknown code)"; +} + +TransportStatus::Impl::Impl(TransportStatusCode code, std::string message, + std::vector<std::unique_ptr<StatusDetail>> details) + : code(code), message(std::move(message)), details(std::move(details)) { + DCHECK_NE(code, TransportStatusCode::kOk); +} +TransportStatus::TransportStatus() = default; +TransportStatus::TransportStatus(TransportStatusCode code) + : impl_(code == TransportStatusCode::kOk + ? nullptr + : std::make_unique<Impl>(code, "", + std::vector<std::unique_ptr<StatusDetail>>{})) {} Review Comment: Can we use other constructor here? ```suggestion : TransportStatus(code, "", {}) {} ``` ########## cpp/src/arrow/flight/transport/grpc/grpc_client.cc: ########## @@ -28,10 +29,12 @@ #include "arrow/util/config.h" #ifdef GRPCPP_PP_INCLUDE #include <grpcpp/grpcpp.h> +#include <grpcpp/support/client_callback.h> #if defined(GRPC_NAMESPACE_FOR_TLS_CREDENTIALS_OPTIONS) #include <grpcpp/security/tls_credentials_options.h> #endif #else +// TODO(https://github.com/apache/arrow/issues/36511): get rid of this branch Review Comment: Done: #36679 -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org