Skip to content

MINIFICPP-2816 Add controller_service::api_implementations to C api#2176

Draft
martinzink wants to merge 1 commit into
apache:gcp_to_c_apifrom
martinzink:c_api_controller_service_traits
Draft

MINIFICPP-2816 Add controller_service::api_implementations to C api#2176
martinzink wants to merge 1 commit into
apache:gcp_to_c_apifrom
martinzink:c_api_controller_service_traits

Conversation

@martinzink
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor

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

This PR extends the C extension API for MiNiFi C++ to let C-based controller services declare and expose multiple "provided interfaces" (additional C++ APIs they implement). The agent surfaces these as api_implementations in class descriptions, and MinifiProcessContextGetControllerService now uses a new get_interface callback to cast a controller service implementation to a requested API type. A new stable-api-sandbox test extension exercises the feature with Dog/Duck controller services that both implement CanFlyControllerApi and NumberOfLegsControllerApi, consumed by a ZooProcessor.

Changes:

  • Added provided_interfaces_* and a get_interface callback to the C controller-service ABI, plumbed through useControllerServiceClassDefinition and useCControllerServiceClassDescription into ClassDescription::api_implementations.
  • Introduced a C++-side ProvidedInterface / createProvidedInterface helper and a ControllerServiceType::minifiSystemControllerServiceType factory.
  • Added a new stable-api-sandbox extension (controller services, processor, init, tests, CMake) demonstrating and testing the multi-interface controller service flow.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
minifi-api/include/minifi-c/minifi-c.h Adds provided_interfaces_* fields and get_interface callback to controller-service C ABI structs.
minifi-api/include/minifi-cpp/core/ControllerServiceType.h Adds minifiSystemControllerServiceType factory and tightens reformatting; private ctor for raw fields.
minifi-api/common/include/minifi-cpp/core/ProvidedControllerServiceInterface.h New header defining ProvidedInterface and the createProvidedInterface helper template.
extension-framework/cpp-extension-lib/include/api/core/Resource.h Wires Class::ProvidedInterfaces into the C definition and implements the get_interface lambda.
libminifi/src/minifi-c.cpp Builds api_implementations from C-side interface names; uses get_interface in MinifiProcessContextGetControllerService.
extensions/stable-api-sandbox/AnimalControllerServiceApis.h Defines two abstract controller-service APIs used by the sandbox tests.
extensions/stable-api-sandbox/AnimalControllerServices.{h,cpp} DogController/DuckController implementing both APIs and declaring ProvidedInterfaces.
extensions/stable-api-sandbox/ZooProcessor.{h,cpp} Test processor that fetches both interfaces from configured controller services.
extensions/stable-api-sandbox/ExtensionInitializer.cpp Registers the new processor and controller services as a C extension.
extensions/stable-api-sandbox/CMakeLists.txt New CMake module building the sandbox extension.
extensions/stable-api-sandbox/tests/CMakeLists.txt Builds the sandbox extension's tests.
extensions/stable-api-sandbox/tests/ZooTests.cpp End-to-end test exercising multi-interface lookup via the C API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread extensions/stable-api-sandbox/ExtensionInitializer.cpp Outdated
Comment thread minifi-api/include/minifi-c/minifi-c.h
Comment thread libminifi/src/minifi-c.cpp Outdated
Comment thread extensions/stable-api-sandbox/AnimalControllerServiceApis.h
@martinzink martinzink force-pushed the c_api_controller_service_traits branch from 615a1aa to 8a61732 Compare May 15, 2026 12:35
@martinzink martinzink changed the base branch from main to gcp_to_c_api May 15, 2026 12:35
@martinzink martinzink requested a review from Copilot May 15, 2026 12:36
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Comment on lines +211 to +215
struct MinifiControllerServiceProvidedAPI {
MinifiStringView type;
void*(*cast_api)(void*);
};

Comment on lines +280 to +285
std::vector<core::ControllerServiceType> implements_apis;
implements_apis.reserve(class_description.provided_interfaces_count);
for (size_t i = 0; i < class_description.provided_interfaces_count; ++i) {
auto api_segments = string::split(toStringView(class_description.provided_interfaces_ptr[i]), "::");
implements_apis.push_back(core::ControllerServiceType::minifiSystemControllerServiceType(string::join(".", api_segments)));
}
Comment on lines +20 to +22
#include "core/ClassName.h"

namespace org::apache::nifi::minifi::core {
Comment on lines +49 to +65
const auto& result = controller.trigger();
CHECK(LogTestController::getInstance().contains("[org::apache::nifi::minifi::api_sandbox::ZooProcessor] [critical] Can fly? true"));
CHECK(LogTestController::getInstance().contains("[org::apache::nifi::minifi::api_sandbox::ZooProcessor] [critical] Num of legs? 2"));
}
{
LogTestController::getInstance().clear();
CHECK(controller.getProcessor()->setProperty(ZooProcessor::CanFlyService.name, "duck"));
CHECK(controller.getProcessor()->setProperty(ZooProcessor::NumberOfLegsService.name, "duck"));
const auto& result = controller.trigger();
CHECK(LogTestController::getInstance().contains("[org::apache::nifi::minifi::api_sandbox::ZooProcessor] [critical] Can fly? true"));
CHECK(LogTestController::getInstance().contains("[org::apache::nifi::minifi::api_sandbox::ZooProcessor] [critical] Num of legs? 2"));
}
{
LogTestController::getInstance().clear();
CHECK(controller.getProcessor()->setProperty(ZooProcessor::CanFlyService.name, "duck"));
CHECK(controller.getProcessor()->setProperty(ZooProcessor::NumberOfLegsService.name, "invalid"));
const auto& result = controller.trigger();

const auto duck = minifi::test::utils::make_custom_c_controller_service<DuckController>(core::ControllerServiceMetadata{utils::Identifier{},
"DuckController",
logging::LoggerFactory<DogController>::getLogger()});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants