You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/01/20 14:44:31 UTC

[GitHub] [arrow] lidavidm commented on a change in pull request #12196: [RFC] ARROW-15282: [C++][FlightRPC] Support non-grpc data planes

lidavidm commented on a change in pull request #12196:
URL: https://github.com/apache/arrow/pull/12196#discussion_r788828887



##########
File path: cpp/src/arrow/flight/data_plane/types.cc
##########
@@ -0,0 +1,127 @@
+// 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.
+
+#include "arrow/flight/data_plane/types.h"
+#include "arrow/flight/data_plane/internal.h"
+#include "arrow/util/io_util.h"
+#include "arrow/util/logging.h"
+#include "arrow/util/make_unique.h"
+
+#ifdef GRPCPP_PP_INCLUDE
+#include <grpcpp/grpcpp.h>
+#else
+#include <grpc++/grpc++.h>
+#endif
+
+namespace arrow {
+namespace flight {
+namespace internal {
+
+namespace {
+
+// data plane registry (name -> data plane maker)
+struct Registry {
+  std::map<const std::string, DataPlaneMaker> makers;
+
+  // register all data planes on creation of registry singleton
+  Registry() {
+#ifdef FLIGHT_DP_SHM
+    Register("shm", GetShmDataPlaneMaker());
+#endif
+  }
+
+  static const Registry& instance() {
+    static const Registry registry;
+    return registry;
+  }
+
+  void Register(const std::string& name, const DataPlaneMaker& maker) {
+    DCHECK_EQ(makers.find(name), makers.end());
+    makers[name] = maker;
+  }
+
+  arrow::Result<DataPlaneMaker> GetDataPlaneMaker(const std::string& uri) const {
+    const std::string name = uri.substr(0, uri.find(':'));
+    auto it = makers.find(name);
+    if (it == makers.end()) {
+      return Status::Invalid("unknown data plane: ", name);
+    }
+    return it->second;
+  }
+};
+
+std::string GetGrpcMetadata(const grpc::ServerContext& context, const std::string& key) {
+  const auto client_metadata = context.client_metadata();
+  const auto found = client_metadata.find(key);
+  std::string token;
+  if (found == client_metadata.end()) {
+    DCHECK(false);
+    token = "";
+  } else {
+    token = std::string(found->second.data(), found->second.length());
+  }
+  return token;
+}
+
+// TODO(yibo): getting data plane uri from env var is bad, shall we extend
+// location to support two uri (control, data)? or any better approach to

Review comment:
       `grpc+tcp://localhost:1337/?data=shm` or something? Or maybe something like `grpc+tcp+shm://...` not sure what is semantically correct.




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