martinzink commented on code in PR #2096:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2096#discussion_r2799367623
##########
libminifi/src/minifi-c.cpp:
##########
@@ -440,8 +512,58 @@ void MinifiFlowFileGetAttributes(MinifiProcessSession*
session, MinifiFlowFile*
gsl_Assert(session != MINIFI_NULL);
gsl_Assert(flowfile != MINIFI_NULL);
for (auto& [key, value] :
(*reinterpret_cast<std::shared_ptr<minifi::core::FlowFile>*>(flowfile))->getAttributes())
{
- cb(user_ctx, MinifiStringView{.data = key.data(), .length = key.size()},
MinifiStringView{.data = value.data(), .length = value.size()});
+ cb(user_ctx, minifiStringView(key), minifiStringView(value));
+ }
+}
+
+MinifiStatus
MinifiControllerServiceContextGetProperty(MinifiControllerServiceContext*
context, MinifiStringView property_name,
+ void (*result_cb)(void* user_ctx, MinifiStringView result), void*
user_ctx) {
+ gsl_Assert(context != MINIFI_NULL);
+ auto result =
reinterpret_cast<minifi::core::controller::ControllerServiceContext*>(context)->getProperty(toStringView(property_name));
+ if (result) {
+ result_cb(user_ctx, minifiStringView(result.value()));
+ return MINIFI_STATUS_SUCCESS;
+ }
+ switch
(static_cast<minifi::core::PropertyErrorCode>(result.error().value())) {
+ case minifi::core::PropertyErrorCode::NotSupportedProperty: return
MINIFI_STATUS_NOT_SUPPORTED_PROPERTY;
+ case minifi::core::PropertyErrorCode::DynamicPropertiesNotSupported:
return MINIFI_STATUS_DYNAMIC_PROPERTIES_NOT_SUPPORTED;
+ case minifi::core::PropertyErrorCode::PropertyNotSet: return
MINIFI_STATUS_PROPERTY_NOT_SET;
+ case minifi::core::PropertyErrorCode::ValidationFailed: return
MINIFI_STATUS_VALIDATION_FAILED;
+ default: return MINIFI_STATUS_UNKNOWN_ERROR;
}
}
+
+MinifiStatus MinifiProcessContextGetControllerService(
+ MinifiProcessContext* process_context,
+ MinifiStringView controller_service_name,
+ void(*cb)(
+ void* user_ctx,
+ void* service,
+ MinifiStringView type,
+ MinifiStringView group,
+ MinifiStringView version),
+ void* user_ctx) {
+
+ gsl_Assert(process_context != MINIFI_NULL);
+ const auto context =
reinterpret_cast<minifi::core::ProcessContext*>(process_context);
+ const auto name_str = std::string{toStringView(controller_service_name)};
+ const auto service_shared_ptr = context->getControllerService(name_str,
context->getProcessorInfo().getUUID());
+ if (!service_shared_ptr) {
+ return MINIFI_STATUS_UNKNOWN_ERROR;
+ }
+ const minifi::utils::CControllerService* c_controller_service =
dynamic_cast<minifi::utils::CControllerService*>(&*service_shared_ptr);
+ if (c_controller_service) {
+ const auto class_description = c_controller_service->getClassDescription();
+ cb(user_ctx,
+ c_controller_service->getImpl(),
+ minifiStringView(class_description.group_name),
+ minifiStringView(class_description.name),
Review Comment:
nice catch, I've consistently switched these up in my rust bindings aswell
fixed in
https://github.com/apache/nifi-minifi-cpp/pull/2096/changes/0a5d4de40cabddf0b63c13f840b0b8e3b9cbb4d5#diff-e605b773f18dbbf72485a3ac29e620d5478929592fb225caeaf6d606f8974dc7R543-R544
--
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]