You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "adamdebreceni (via GitHub)" <gi...@apache.org> on 2025/10/29 13:03:07 UTC
[PR] MINIFICPP-2657 - Explicit extension initialization [nifi-minifi-cpp]
adamdebreceni opened a new pull request, #2054:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2054
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file?
- [ ] If applicable, have you updated the NOTICE file?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
--
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
Re: [PR] MINIFICPP-2657 - Explicit extension initialization [nifi-minifi-cpp]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2054:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2054#discussion_r2473393789
##########
Extensions.md:
##########
@@ -33,20 +33,22 @@ REGISTER_RESOURCE(RESTSender, DescriptionOnly);
```
Some extensions (e.g. `OpenCVExtension`) require initialization before use.
-You need to create `init` and `deinit` functions and register them using `REGISTER_EXTENSION`.
+You need to define an `InitExtension` function to be called.
```C++
-static bool init(const std::shared_ptr<org::apache::nifi::minifi::Configure>& /*config*/) {
- return org::apache::nifi::minifi::utils::Environment::setEnvironmentVariable("OPENCV_FFMPEG_CAPTURE_OPTIONS", "rtsp_transport;udp", false /*overwrite*/);
+extern "C" std::optional<org::apache::nifi:minifi::core::extension::ExtensionInfo> InitExtension(const std::shared_ptr<org::apache::nifi::minifi::Configure>& /*config*/) {
+ org::apache::nifi::minifi::utils::Environment::setEnvironmentVariable("OPENCV_FFMPEG_CAPTURE_OPTIONS", "rtsp_transport;udp", false /*overwrite*/);
+ return org::apache::nifi:minifi::core::extension::ExtensionInfo{
Review Comment:
Corrected namespace separator from single colon to double colon: 'nifi:minifi' should be 'nifi::minifi'.
##########
Extensions.md:
##########
@@ -33,20 +33,22 @@ REGISTER_RESOURCE(RESTSender, DescriptionOnly);
```
Some extensions (e.g. `OpenCVExtension`) require initialization before use.
-You need to create `init` and `deinit` functions and register them using `REGISTER_EXTENSION`.
+You need to define an `InitExtension` function to be called.
```C++
-static bool init(const std::shared_ptr<org::apache::nifi::minifi::Configure>& /*config*/) {
- return org::apache::nifi::minifi::utils::Environment::setEnvironmentVariable("OPENCV_FFMPEG_CAPTURE_OPTIONS", "rtsp_transport;udp", false /*overwrite*/);
+extern "C" std::optional<org::apache::nifi:minifi::core::extension::ExtensionInfo> InitExtension(const std::shared_ptr<org::apache::nifi::minifi::Configure>& /*config*/) {
Review Comment:
Corrected namespace separator from single colon to double colon: 'nifi:minifi' should be 'nifi::minifi'.
##########
extensions/sftp/SFTPLoader.cpp:
##########
@@ -16,23 +16,33 @@
* limitations under the License.
*/
-#include "core/extension/Extension.h"
+#include "minifi-cpp/core/extension/ExtensionInfo.h"
+#include "minifi-cpp/agent/agent_version.h"
+#include "minifi-cpp/properties/Configure.h"
#include "client/SFTPClient.h"
-static bool init(const std::shared_ptr<org::apache::nifi::minifi::Configure>& /*config*/) {
- if (libssh2_init(0) != 0) {
- return false;
- }
- if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK) {
- libssh2_exit();
- return false;
- }
- return true;
-}
+namespace minifi = org::apache::nifi::minifi;
static void deinit() {
curl_global_cleanup();
libssh2_exit();
}
-REGISTER_EXTENSION("SFTPExtension", init, deinit);
+extern "C" std::optional<minifi::core::extension::ExtensionInfo> InitExtension(const std::shared_ptr<minifi::Configure>& config) {
+ if (libssh2_init(0) != 0) {
+ return std::nullopt;
+ }
+ if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK) {
+ libssh2_exit();
+ return std::nullopt;
+ }
+ return minifi::core::extension::ExtensionInfo{
+ .name = "SFTPExtension",
+ .version = minifi::AgentBuild::VERSION,
+ .deinit = [] (void* /*ctx*/) {
+ curl_global_cleanup();
+ libssh2_exit();
+ },
Review Comment:
The deinitialization logic is duplicated. The `deinit()` function at line 26-29 performs the same cleanup but is never called. Consider removing the standalone `deinit()` function to eliminate code duplication.
--
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
Re: [PR] MINIFICPP-2657 - Explicit extension initialization [nifi-minifi-cpp]
Posted by "adamdebreceni (via GitHub)" <gi...@apache.org>.
adamdebreceni closed pull request #2054: MINIFICPP-2657 - Explicit extension initialization
URL: https://github.com/apache/nifi-minifi-cpp/pull/2054
--
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
Re: [PR] MINIFICPP-2657 - Explicit extension initialization [nifi-minifi-cpp]
Posted by "adamdebreceni (via GitHub)" <gi...@apache.org>.
adamdebreceni commented on PR #2054:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2054#issuecomment-3471712554
as I have basically changed the whole PR, i am closing this and reopening it
--
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
Re: [PR] MINIFICPP-2657 - Explicit extension initialization [nifi-minifi-cpp]
Posted by "szaszm (via GitHub)" <gi...@apache.org>.
szaszm commented on code in PR #2054:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2054#discussion_r2477887313
##########
minifi-api/include/minifi-cpp/core/extension/ExtensionInfo.h:
##########
@@ -17,16 +18,19 @@
#pragma once
-#include "Extension.h"
+#include <string>
+#include <optional>
+#include "minifi-cpp/properties/Configure.h"
namespace org::apache::nifi::minifi::core::extension {
-class ExtensionManager {
- public:
- static ExtensionManager& get();
-
- virtual void registerExtension(Extension& extension) = 0;
- virtual void unregisterExtension(Extension& extension) = 0;
+struct ExtensionInfo {
+ std::string name;
+ std::string version;
Review Comment:
the return type should not contain C++ types either. I could imagine a `const char*` pointing to a static string within the extension.
##########
extensions/opencv/OpenCVLoader.cpp:
##########
@@ -15,18 +15,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "core/extension/Extension.h"
+#include "minifi-cpp/core/extension/ExtensionInfo.h"
+#include "minifi-cpp/properties/Configure.h"
#include "utils/Environment.h"
+#include "minifi-cpp/agent/agent_version.h"
-static bool init(const std::shared_ptr<org::apache::nifi::minifi::Configure>& /*config*/) {
+namespace minifi = org::apache::nifi::minifi;
+
+extern "C" minifi::core::extension::ExtensionInitializer InitExtension = [] (const std::shared_ptr<minifi::Configure>& /*config*/) -> std::optional<minifi::core::extension::ExtensionInfo> {
Review Comment:
I think this could stay a normal function. Also not sure if shared_ptr and C++ types are a good idea here, I would use C types.
--
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
Re: [PR] MINIFICPP-2657 - Explicit extension initialization [nifi-minifi-cpp]
Posted by "szaszm (via GitHub)" <gi...@apache.org>.
szaszm commented on code in PR #2054:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2054#discussion_r2477804926
##########
extensions/opencv/OpenCVLoader.cpp:
##########
@@ -15,18 +15,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "core/extension/Extension.h"
+#include "minifi-cpp/core/extension/ExtensionInfo.h"
+#include "minifi-cpp/properties/Configure.h"
#include "utils/Environment.h"
+#include "minifi-cpp/agent/agent_version.h"
-static bool init(const std::shared_ptr<org::apache::nifi::minifi::Configure>& /*config*/) {
+namespace minifi = org::apache::nifi::minifi;
+
+extern "C" minifi::core::extension::ExtensionInitializer InitExtension = [] (const std::shared_ptr<minifi::Configure>& /*config*/) -> std::optional<minifi::core::extension::ExtensionInfo> {
Review Comment:
I think this could stay a normal function. Also not sure if shared_ptr and C++ types are a good idea here, I would use C types.
config: doesn't really need ownership, could be a lookup callback (`const char* (*)(const char* config_key)`) or a flat array of config properties (array of structs with 2 const char* members or array of const char* with `=` separator between key/value)
result: drop the optional, let's say a negative version means unsuccessful extension init
--
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
Re: [PR] MINIFICPP-2657 - Explicit extension initialization [nifi-minifi-cpp]
Posted by "adamdebreceni (via GitHub)" <gi...@apache.org>.
adamdebreceni commented on code in PR #2054:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2054#discussion_r2474253099
##########
extensions/sftp/SFTPLoader.cpp:
##########
@@ -16,23 +16,33 @@
* limitations under the License.
*/
-#include "core/extension/Extension.h"
+#include "minifi-cpp/core/extension/ExtensionInfo.h"
+#include "minifi-cpp/agent/agent_version.h"
+#include "minifi-cpp/properties/Configure.h"
#include "client/SFTPClient.h"
-static bool init(const std::shared_ptr<org::apache::nifi::minifi::Configure>& /*config*/) {
- if (libssh2_init(0) != 0) {
- return false;
- }
- if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK) {
- libssh2_exit();
- return false;
- }
- return true;
-}
+namespace minifi = org::apache::nifi::minifi;
static void deinit() {
curl_global_cleanup();
libssh2_exit();
}
-REGISTER_EXTENSION("SFTPExtension", init, deinit);
+extern "C" std::optional<minifi::core::extension::ExtensionInfo> InitExtension(const std::shared_ptr<minifi::Configure>& config) {
+ if (libssh2_init(0) != 0) {
+ return std::nullopt;
+ }
+ if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK) {
+ libssh2_exit();
+ return std::nullopt;
+ }
+ return minifi::core::extension::ExtensionInfo{
+ .name = "SFTPExtension",
+ .version = minifi::AgentBuild::VERSION,
+ .deinit = [] (void* /*ctx*/) {
+ curl_global_cleanup();
+ libssh2_exit();
+ },
Review Comment:
removed
--
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