MINIFICPP-2752 - Register processors one-by-one#2150
MINIFICPP-2752 - Register processors one-by-one#2150adamdebreceni wants to merge 4 commits intoapache:mainfrom
Conversation
2c5414a to
be71b24
Compare
|
|
||
| MinifiStatus MinifiCreateExtension(MinifiExtension* extension, const MinifiExtensionCreateInfo* extension_create_info) { | ||
| gsl_Assert(extension); | ||
| MinifiExtension* MinifiCreateExtension(MinifiExtensionContext* extension_context, const MinifiExtensionCreateInfo* extension_create_info) { |
There was a problem hiding this comment.
I'm thinking maybe we should call this MinifiRegisterExtension, since we're calling the extension-side code "init", and init normally comes at the same time or shortly after create.
| } MinifiExtensionCreateInfo; | ||
|
|
||
| MinifiStatus MINIFI_CREATE_EXTENSION_FN(MinifiExtension* extension, const MinifiExtensionCreateInfo* create_info); | ||
| MinifiExtension* MINIFI_CREATE_EXTENSION_FN(MinifiExtensionContext* extension_context, const MinifiExtensionCreateInfo* create_info); |
There was a problem hiding this comment.
It would be nice to have a comment explaining to readers why this is a macro
There was a problem hiding this comment.
added comment
There was a problem hiding this comment.
Pull request overview
Refactors the stable C extension initialization flow so extensions are created once and then processors can be registered incrementally, aligning better with extensions that discover/register processors dynamically.
Changes:
- Updates the stable C API to introduce
MinifiExtensionContext, changeMinifiCreateExtensionto return an extension handle, and addMinifiRegisterProcessor. - Adjusts core extension initialization to pass an extension context into
MinifiInit*Extensionentrypoints and updates built-in extensions/loaders accordingly. - Updates Windows export definitions, integration tests, and the extensions guide example for the new registration model.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| minifi-api/minifi-c-api.def | Exports new MinifiRegisterProcessor symbol on Windows. |
| minifi-api/include/minifi-c/minifi-c.h | C API signature updates: add MinifiExtensionContext, change create signature, add register API, update config access signature. |
| libminifi/src/minifi-c.cpp | Implements new MinifiCreateExtension return type + MinifiRegisterProcessor, updates MinifiConfigGet to use context. |
| libminifi/src/core/extension/Extension.cpp | Switches extension init entrypoint to MinifiExtensionContext* and wires context-based creation/config access. |
| libminifi/include/core/extension/Extension.h | Introduces Extension::Context and changes info access. |
| extensions/llamacpp/processors/ExtensionInitializer.cpp | Updates C extension init to create once + register processor. |
| extensions/ExtensionInitializer.cpp | Updates generic C++ extension init signature to take context. |
| extensions/opencv/OpenCVLoader.cpp | Updates C++ extension init signature to take context. |
| extensions/python/pythonloader/PyProcLoader.cpp | Uses context-based MinifiConfigGet and updated init signature. |
| extensions/python/pythonlibloader/PythonLibLoader.cpp | Uses context-based MinifiConfigGet and updated init signature. |
| extensions/sftp/SFTPLoader.cpp | Updates C++ extension init signature to take context. |
| extension-framework/include/utils/ExtensionInitUtils.h | Updates helper wrapper to call new create signature. |
| libminifi/test/integration/extension-verification-test/ExtensionVerificationTests.cpp | Updates custom create hook signature used by tests. |
| libminifi/test/integration/extension-verification-test/CreateNotCalled.cpp | Updates C extension init signature for “create not called” test. |
| libminifi/test/integration/extension-verification-test/CppApiExtension.cpp | Updates C++ extension init signature + create info initialization. |
| libminifi/test/integration/extension-verification-test/CApiExtension.cpp | Updates C extension init signature + create info initialization. |
| Extensions.md | Updates C-extension example to create once and register processors one-by-one. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .deinit = nullptr, | ||
| .user_data = nullptr | ||
| }; | ||
| auto* extension = MinifiCreateExtension(extension_context, &ext_create_info); |
There was a problem hiding this comment.
MinifiCreateExtension() can return MINIFI_NULL (e.g., if creation fails or is called more than once). The returned pointer is used unconditionally in MinifiRegisterProcessor, which will hit gsl_Assert(extension_handle) and abort. Please guard extension and handle the error path (or check the returned MinifiStatus) before registering processors.
| auto* extension = MinifiCreateExtension(extension_context, &ext_create_info); | |
| auto* extension = MinifiCreateExtension(extension_context, &ext_create_info); | |
| if (extension == MINIFI_NULL) { | |
| return; | |
| } |
02c006c to
b295553
Compare
depends on
Used by
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:
For documentation related changes:
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.