adamdebreceni commented on code in PR #1504:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1504#discussion_r1118424597
##########
extensions/script/ScriptExecutor.h:
##########
@@ -18,39 +18,31 @@
#pragma once
#include <memory>
-#include <string>
-#include <vector>
#include <utility>
-#include <filesystem>
-
-namespace org::apache::nifi::minifi::script {
+#include <string>
+#include <variant>
-class ScriptEngine {
- public:
- /**
- * Evaluates the given script string, storing the expression's result into
res_var, if res_var is not empty.
- * @param script
- * @param res_var
- */
- virtual void eval(const std::string &script) = 0;
+#include "Core.h"
+#include "ProcessContext.h"
+#include "ProcessSession.h"
- /**
- * Evaluates the given script file, storing the expression's result into
res_var, if res_var is not empty.
- * @param script
- * @param res_var
- */
- virtual void evalFile(const std::string &file_name) = 0;
+namespace org::apache::nifi::minifi::extensions::script {
- void setModulePaths(std::vector<std::filesystem::path>&& module_paths) {
- module_paths_ = std::move(module_paths);
- }
+class ScriptExecutor : public minifi::core::CoreComponent {
+ public:
+ ScriptExecutor(std::string name, const utils::Identifier& uuid) :
core::CoreComponent(std::move(name), uuid) {}
virtual void onTrigger(const std::shared_ptr<core::ProcessContext> &context,
const std::shared_ptr<core::ProcessSession> &session) = 0;
-
- virtual ~ScriptEngine() = default;
+ virtual void initialize(std::filesystem::path script_file,
+ std::string script_body,
+ std::optional<std::string> module_directory,
+ size_t max_concurrent_engines,
+ const core::Relationship& success,
+ const core::Relationship& failure,
+ std::shared_ptr<core::logging::Logger> logger) = 0;
protected:
- std::vector<std::filesystem::path> module_paths_;
+ std::variant<std::filesystem::path, std::string> script_to_run_;
Review Comment:
I think a variant like this will default construct the first type, and
always contain one of its types, to create an "nullable" variant I think
`std::monostate` is used
--
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]