Skip to content

MINIFICPP-2752 - Register processors one-by-one#2150

Open
adamdebreceni wants to merge 4 commits intoapache:mainfrom
adamdebreceni:MINIFICPP-2752
Open

MINIFICPP-2752 - Register processors one-by-one#2150
adamdebreceni wants to merge 4 commits intoapache:mainfrom
adamdebreceni:MINIFICPP-2752

Conversation

@adamdebreceni
Copy link
Copy Markdown
Contributor

@adamdebreceni adamdebreceni commented Mar 30, 2026

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:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • 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.

@martinzink martinzink added this to the minifi-rust milestone Mar 30, 2026
martinzink added a commit to martinzink/nifi-minifi-cpp that referenced this pull request Mar 30, 2026
Copy link
Copy Markdown
Member

@martinzink martinzink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great improvement 👍

Comment thread Extensions.md Outdated
@martinzink martinzink added the priority Review these first label Apr 9, 2026
@adamdebreceni adamdebreceni changed the base branch from MINIFICPP-2715 to main April 10, 2026 09:56
Comment thread libminifi/src/minifi-c.cpp Outdated

MinifiStatus MinifiCreateExtension(MinifiExtension* extension, const MinifiExtensionCreateInfo* extension_create_info) {
gsl_Assert(extension);
MinifiExtension* MinifiCreateExtension(MinifiExtensionContext* extension_context, const MinifiExtensionCreateInfo* extension_create_info) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

Comment thread minifi-api/include/minifi-c/minifi-c.h Outdated
} MinifiExtensionCreateInfo;

MinifiStatus MINIFI_CREATE_EXTENSION_FN(MinifiExtension* extension, const MinifiExtensionCreateInfo* create_info);
MinifiExtension* MINIFI_CREATE_EXTENSION_FN(MinifiExtensionContext* extension_context, const MinifiExtensionCreateInfo* create_info);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a comment explaining to readers why this is a macro

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, change MinifiCreateExtension to return an extension handle, and add MinifiRegisterProcessor.
  • Adjusts core extension initialization to pass an extension context into MinifiInit*Extension entrypoints 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.

Comment thread libminifi/include/core/extension/Extension.h
Comment thread libminifi/include/core/extension/Extension.h Outdated
Comment thread libminifi/src/minifi-c.cpp Outdated
Comment thread libminifi/src/core/extension/Extension.cpp
Comment thread minifi-api/include/minifi-c/minifi-c.h Outdated
.deinit = nullptr,
.user_data = nullptr
};
auto* extension = MinifiCreateExtension(extension_context, &ext_create_info);
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
auto* extension = MinifiCreateExtension(extension_context, &ext_create_info);
auto* extension = MinifiCreateExtension(extension_context, &ext_create_info);
if (extension == MINIFI_NULL) {
return;
}

Copilot uses AI. Check for mistakes.
Comment thread Extensions.md
@fgerlits fgerlits self-requested a review April 16, 2026 13:11
@lordgamez lordgamez self-requested a review April 17, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority Review these first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants