szaszm commented on a change in pull request #1232:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1232#discussion_r781149292
##########
File path: extensions/script/ExecuteScript.h
##########
@@ -28,17 +28,95 @@
#include "ScriptEngine.h"
#include "ScriptProcessContext.h"
+#include "utils/Enum.h"
namespace org {
namespace apache {
namespace nifi {
namespace minifi {
+
+#ifdef PYTHON_SUPPORT
+namespace python {
+class PythonScriptEngine;
+}
+#endif // PYTHON_SUPPORT
+
namespace processors {
+class ScriptEngineFactory {
+ public:
+ ScriptEngineFactory(core::Relationship& success, core::Relationship&
failure, std::shared_ptr<core::logging::Logger> logger);
+
+ template<typename T>
+ std::shared_ptr<T> createEngine() const {
+ auto engine = std::make_shared<T>();
+
+ engine->bind("log", logger_);
+ engine->bind("REL_SUCCESS", success_);
+ engine->bind("REL_FAILURE", failure_);
+
+ return engine;
+ }
+
+ private:
+ core::Relationship& success_;
+ core::Relationship& failure_;
+ std::shared_ptr<core::logging::Logger> logger_;
+};
+
+class ScriptEngineQueue {
+ public:
+ ScriptEngineQueue(uint8_t max_engine_count, ScriptEngineFactory&
engine_factory, std::shared_ptr<core::logging::Logger> logger);
+
+ template<typename T>
+ std::shared_ptr<script::ScriptEngine> getScriptEngine() {
Review comment:
How is it enforced that the returned script engine is of type `T`,
especially if it's taken out of the queue? It looks like the queue can contain
any kind of script engine and this function just takes out whatever is at the
end.
##########
File path: extensions/script/ExecuteScript.h
##########
@@ -28,17 +28,95 @@
#include "ScriptEngine.h"
#include "ScriptProcessContext.h"
+#include "utils/Enum.h"
namespace org {
namespace apache {
namespace nifi {
namespace minifi {
+
+#ifdef PYTHON_SUPPORT
+namespace python {
+class PythonScriptEngine;
+}
+#endif // PYTHON_SUPPORT
+
namespace processors {
+class ScriptEngineFactory {
+ public:
+ ScriptEngineFactory(core::Relationship& success, core::Relationship&
failure, std::shared_ptr<core::logging::Logger> logger);
+
+ template<typename T>
+ std::shared_ptr<T> createEngine() const {
+ auto engine = std::make_shared<T>();
Review comment:
I think it would make sense to add some restriction, e.g. that `T` is
derived from `ScriptEngine`.
```suggestion
template<typename T>
std::enable_if_t<std::is_base_of_v<script::ScriptEngine, T>,
std::shared_ptr<T>> createEngine() const {
auto engine = std::make_shared<T>();
```
--
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]