lidavidm commented on a change in pull request #12465: URL: https://github.com/apache/arrow/pull/12465#discussion_r813976795
########## File path: cpp/src/arrow/flight/transport_impl.h ########## @@ -0,0 +1,221 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Internal (but not private) interface for implementing alternate +// transports in Flight. +// +// EXPERIMENTAL. Subject to change. + +#pragma once + +#include <chrono> +#include <functional> +#include <memory> +#include <string> +#include <utility> +#include <vector> + +#include "arrow/flight/type_fwd.h" +#include "arrow/flight/visibility.h" +#include "arrow/type_fwd.h" + +namespace arrow { +namespace ipc { +class Message; +} +namespace flight { +namespace internal { + +/// Internal, not user-visible type used for memory-efficient reads from gRPC +/// stream +struct FlightData { + /// Used only for puts, may be null + std::unique_ptr<FlightDescriptor> descriptor; + + /// Non-length-prefixed Message header as described in format/Message.fbs + std::shared_ptr<Buffer> metadata; + + /// Application-defined metadata + std::shared_ptr<Buffer> app_metadata; + + /// Message body + std::shared_ptr<Buffer> body; + + /// Open IPC message from the metadata and body + ::arrow::Result<std::unique_ptr<ipc::Message>> OpenMessage(); +}; + +/// \brief An transport-specific interface for reading/writing Arrow data. +/// +/// New transports will implement this to read/write IPC payloads to +/// the underlying stream. +class ARROW_FLIGHT_EXPORT TransportDataStream { + public: + virtual ~TransportDataStream() = default; + /// \brief Attemnpt to read the next FlightData message. + /// + /// \return success true if data was populated, false if there was + /// an error. For clients, the error can be retrieved from Finish. + virtual bool ReadData(FlightData* data); Review comment: I kept it similar to gRPC's API - so reading only returns boolean success/failure, and to get the 'real' error, you must call Finish. For the server side, Finish does not exist, the server is powerless to do anything if reading fails (the client disconnected or went away), so gRPC doesn't bubble up any more detailed errors. -- 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]
