You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "lidavidm (via GitHub)" <gi...@apache.org> on 2023/06/22 16:29:36 UTC

[GitHub] [arrow] lidavidm commented on a diff in pull request #36205: GH-16604: [C++][FlightRPC] Add async Flight client

lidavidm commented on code in PR #36205:
URL: https://github.com/apache/arrow/pull/36205#discussion_r1238773601


##########
cpp/src/arrow/flight/types_async.h:
##########
@@ -0,0 +1,116 @@
+// 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.
+
+#pragma once
+
+#include <memory>
+
+#include "arrow/flight/type_fwd.h"
+#include "arrow/flight/types.h"
+#include "arrow/ipc/options.h"
+#include "arrow/type_fwd.h"
+
+namespace arrow::flight {
+
+class IpcPutter;
+
+/// \defgroup flight-async Async Flight Types
+/// Common types used for asynchronous Flight APIs.
+/// @{
+
+/// \brief Non-templated state for an async RPC.
+class AsyncListenerBase {
+ public:
+  AsyncListenerBase();
+  virtual ~AsyncListenerBase();
+
+  /// \brief Request cancellation of the RPC.
+  ///
+  /// The RPC is not cancelled until AsyncListener::OnFinish is called.
+  void TryCancel();
+
+ private:
+  friend class arrow::flight::internal::ClientTransport;
+  friend class arrow::flight::IpcPutter;
+
+  /// Transport-specific state for this RPC.  Transport
+  /// implementations may store and retrieve state here via
+  /// ClientTransport::SetAsyncRpc and ClientTransport::GetAsyncRpc.
+  std::unique_ptr<internal::AsyncRpc> rpc_state_;
+};
+
+/// \brief Callbacks for results from async RPCs.
+///
+/// A single listener may not be used for multiple concurrent RPC
+/// calls.  The application MUST hold the listener alive until
+/// OnFinish() is called and has finished.
+template <typename T>
+class ARROW_FLIGHT_EXPORT AsyncListener : public AsyncListenerBase {
+ public:
+  /// \brief Get the next server result.
+  /// This will never be called concurrently with itself or OnFinish.
+  virtual void OnNext(T message) = 0;

Review Comment:
   I think it's best to not have multiple error paths. If we return a Status here, what is the implementation supposed to do with it? It can at best just give it straight back to OnFinish.



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org