You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/11/11 07:59:16 UTC

[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1211: MINIFICPP-1676 - Verify build id of extension before load

adamdebreceni commented on a change in pull request #1211:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1211#discussion_r747277352



##########
File path: libminifi/include/core/extension/Utils.h
##########
@@ -0,0 +1,113 @@
+/**
+ * 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 <optional>
+#include <functional>
+#include <chrono>
+#include <utility>
+#include <memory>
+#include <string>
+
+#include "utils/gsl.h"
+#include "utils/file/FileView.h"
+#include "utils/StringUtils.h"
+
+namespace org::apache::nifi::minifi::core::extension::internal {
+
+struct Timer {
+  explicit Timer(std::function<void(int)> cb): cb_(std::move(cb)) {}
+  ~Timer() {
+    auto end = std::chrono::steady_clock::now();
+    int elapsed = gsl::narrow<int>(std::chrono::duration_cast<std::chrono::milliseconds>(end - start_).count());
+    cb_(elapsed);
+  }
+  std::chrono::steady_clock::time_point start_{std::chrono::steady_clock::now()};
+  std::function<void(int)> cb_;
+};
+
+struct LibraryDescriptor {
+  std::string name;
+  std::filesystem::path dir;
+  std::string filename;
+
+  [[nodiscard]]
+  bool verify(const std::shared_ptr<logging::Logger>& logger) const {
+    auto path = getFullPath();
+    Timer timer{[&] (int ms) {
+      logger->log_error("Verification for '%s' took %d ms", path.string(), ms);
+    }};

Review comment:
       the Timer has been removed as it was a development util and was left in by accident




-- 
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: issues-unsubscribe@nifi.apache.org

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