This is an automated email from the ASF dual-hosted git repository. martinzink pushed a commit to branch minifi_rust_pgp in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 7f6c01d0a4687d7d90ef3bf3330573a1894bc539 Author: Martin Zink <[email protected]> AuthorDate: Mon Aug 17 11:42:39 2026 +0200 K -> P in Property context 2 --- .../src/processors/lorem_ipsum_cs_user/tests.rs | 23 ++++++++++++++---- .../minifi_native/src/api/process_context.rs | 28 +++++++++++----------- .../utils/context_session_flowfile_bundle.rs | 12 +++++----- minifi_rust/minifi_native/src/api/property.rs | 2 +- .../src/c_ffi/c_ffi_controller_service_context.rs | 4 ++-- .../src/c_ffi/c_ffi_process_context.rs | 10 ++++---- .../src/mock/mock_controller_service_context.rs | 4 ++-- .../minifi_native/src/mock/mock_process_context.rs | 14 +++++------ 8 files changed, 55 insertions(+), 42 deletions(-) diff --git a/minifi_rust/extensions/minifi_rs_playground/src/processors/lorem_ipsum_cs_user/tests.rs b/minifi_rust/extensions/minifi_rs_playground/src/processors/lorem_ipsum_cs_user/tests.rs index 8a3ad0340..ccf46ac84 100644 --- a/minifi_rust/extensions/minifi_rs_playground/src/processors/lorem_ipsum_cs_user/tests.rs +++ b/minifi_rust/extensions/minifi_rs_playground/src/processors/lorem_ipsum_cs_user/tests.rs @@ -15,8 +15,12 @@ // specific language governing permissions and limitations // under the License. +use crate::controller_services::lorem_ipsum_controller_service::LoremIpsumControllerService; use crate::processors::lorem_ipsum_cs_user::LoremIpsumCSUser; -use minifi_native::{ComponentIdentifier, MockLogger, MockProcessContext, Schedule}; +use minifi_native::{ + ComponentIdentifier, EnableControllerService, FlowFileSource, MockLogger, MockProcessContext, + Schedule, +}; #[test] fn test_ids() { @@ -29,8 +33,17 @@ fn test_ids() { } #[test] -fn schedules_with_controller() { - let context = MockProcessContext::new(); - let schedule_result = LoremIpsumCSUser::schedule(&context, &MockLogger::new()); - assert!(schedule_result.is_ok()); +fn lorem_ipsum_trigger() { + let mut context = MockProcessContext::new(); + let logger = MockLogger::new(); + let lorem_ipsum_user = LoremIpsumCSUser::schedule(&context, &logger).expect("should schedule"); + let lorem_ipsum_cs = LoremIpsumControllerService::enable(&context, &logger).expect(""); + context + .controller_services + .insert("service".into(), Box::new(lorem_ipsum_cs)); + context + .properties + .insert("Lorem Ipsum Controller Service", "service"); + let res = lorem_ipsum_user.generate(&mut context, &logger).unwrap(); + assert_eq!(res.len(), 1); } diff --git a/minifi_rust/minifi_native/src/api/process_context.rs b/minifi_rust/minifi_native/src/api/process_context.rs index 672255dd4..08b172430 100644 --- a/minifi_rust/minifi_native/src/api/process_context.rs +++ b/minifi_rust/minifi_native/src/api/process_context.rs @@ -24,19 +24,19 @@ use crate::{ControllerServiceApi, EnableControllerService, GetProperty, MinifiEr pub trait ProcessContext { type FlowFile: FlowFile; - fn get_raw_property<K: PropertySchema + ?Sized>( + fn get_raw_property<P: PropertySchema + ?Sized>( &self, - property: &Property<K>, + property: &Property<P>, flow_file: Option<&Self::FlowFile>, ) -> Result<Option<String>, MinifiError>; - fn get_raw_controller_service<Cs, K>( + fn get_raw_controller_service<Cs, P>( &self, - property: &Property<K>, + property: &Property<P>, ) -> Result<Option<&Cs>, MinifiError> where Cs: RawControllerService + ComponentIdentifier + 'static, - K: PropertySchema + ?Sized; + P: PropertySchema + ?Sized; fn get_controller_service<Cs>( &self, @@ -57,9 +57,9 @@ impl<S> GetProperty for S where S: ProcessContext, { - fn get_raw_property<K: PropertySchema + ?Sized>( + fn get_raw_property<P: PropertySchema + ?Sized>( &self, - property: &Property<K>, + property: &Property<P>, ) -> Result<Option<String>, MinifiError> { self.get_raw_property(property, None) } @@ -69,15 +69,15 @@ impl<S> GetControllerService for S where S: ProcessContext, { - fn get_controller_service<K>( + fn get_controller_service<P>( &self, - property: &Property<K>, - ) -> Result<K::Output<'_>, MinifiError> + property: &Property<P>, + ) -> Result<P::Output<'_>, MinifiError> where - K: ControllerServiceValue + ?Sized, + P: ControllerServiceValue + ?Sized, { - let cs_property = property.with_marker::<K::Cs>(); - let service = ProcessContext::get_controller_service::<K::Cs>(self, &cs_property)?; - K::from_service(service, property.name) + let cs_property = property.with_marker::<P::Cs>(); + let service = ProcessContext::get_controller_service::<P::Cs>(self, &cs_property)?; + P::from_service(service, property.name) } } diff --git a/minifi_rust/minifi_native/src/api/processor_wrappers/utils/context_session_flowfile_bundle.rs b/minifi_rust/minifi_native/src/api/processor_wrappers/utils/context_session_flowfile_bundle.rs index 4f0716c77..d6c65b6ca 100644 --- a/minifi_rust/minifi_native/src/api/processor_wrappers/utils/context_session_flowfile_bundle.rs +++ b/minifi_rust/minifi_native/src/api/processor_wrappers/utils/context_session_flowfile_bundle.rs @@ -54,9 +54,9 @@ where PC: ProcessContext, PS: ProcessSession<FlowFile = PC::FlowFile>, { - fn get_raw_property<K: PropertySchema + ?Sized>( + fn get_raw_property<P: PropertySchema + ?Sized>( &self, - property: &Property<K>, + property: &Property<P>, ) -> Result<Option<String>, MinifiError> { self.context.get_raw_property(property, self.flow_file) } @@ -67,12 +67,12 @@ where PC: ProcessContext, PS: ProcessSession<FlowFile = PC::FlowFile>, { - fn get_controller_service<K>( + fn get_controller_service<P>( &self, - property: &Property<K>, - ) -> Result<K::Output<'_>, MinifiError> + property: &Property<P>, + ) -> Result<P::Output<'_>, MinifiError> where - K: ControllerServiceValue + ?Sized, + P: ControllerServiceValue + ?Sized, { GetControllerService::get_controller_service(self.context, property) } diff --git a/minifi_rust/minifi_native/src/api/property.rs b/minifi_rust/minifi_native/src/api/property.rs index 41186f1e2..bb8a48db4 100644 --- a/minifi_rust/minifi_native/src/api/property.rs +++ b/minifi_rust/minifi_native/src/api/property.rs @@ -114,7 +114,7 @@ impl<P: ?Sized + PropertySchema> Property<P> { } } - pub(crate) const fn with_marker<K2: ?Sized + PropertySchema>(&self) -> Property<K2> { + pub(crate) const fn with_marker<P2: ?Sized + PropertySchema>(&self) -> Property<P2> { Property { name: self.name, description: self.description, diff --git a/minifi_rust/minifi_native/src/c_ffi/c_ffi_controller_service_context.rs b/minifi_rust/minifi_native/src/c_ffi/c_ffi_controller_service_context.rs index e0efd4afb..2aeb03658 100644 --- a/minifi_rust/minifi_native/src/c_ffi/c_ffi_controller_service_context.rs +++ b/minifi_rust/minifi_native/src/c_ffi/c_ffi_controller_service_context.rs @@ -61,9 +61,9 @@ unsafe extern "C" fn property_callback( } impl<'a> GetProperty for CffiControllerServiceContext<'a> { - fn get_raw_property<K: PropertySchema + ?Sized>( + fn get_raw_property<P: PropertySchema + ?Sized>( &self, - property: &Property<K>, + property: &Property<P>, ) -> Result<Option<String>, MinifiError> { let mut result: Option<String> = None; let property_name: StringView = StringView::new(property.name); diff --git a/minifi_rust/minifi_native/src/c_ffi/c_ffi_process_context.rs b/minifi_rust/minifi_native/src/c_ffi/c_ffi_process_context.rs index 4604b24a5..d7545a766 100644 --- a/minifi_rust/minifi_native/src/c_ffi/c_ffi_process_context.rs +++ b/minifi_rust/minifi_native/src/c_ffi/c_ffi_process_context.rs @@ -65,9 +65,9 @@ unsafe extern "C" fn get_property_callback( impl<'a> ProcessContext for CffiProcessContext<'a> { type FlowFile = CffiFlowFile<'a>; // FlowFile shouldn't outlive the ProcessContext - fn get_raw_property<K: PropertySchema + ?Sized>( + fn get_raw_property<P: PropertySchema + ?Sized>( &self, - property: &Property<K>, + property: &Property<P>, flow_file: Option<&Self::FlowFile>, ) -> Result<Option<String>, MinifiError> { let ff_ptr = flow_file.map_or(std::ptr::null_mut(), |ff| ff.get_ptr()); @@ -94,13 +94,13 @@ impl<'a> ProcessContext for CffiProcessContext<'a> { } } - fn get_raw_controller_service<Cs, K>( + fn get_raw_controller_service<Cs, P>( &self, - property: &Property<K>, + property: &Property<P>, ) -> Result<Option<&'a Cs>, MinifiError> where Cs: ComponentIdentifier + 'static, - K: PropertySchema + ?Sized, + P: PropertySchema + ?Sized, { let str_view = StringView::new(property.name); diff --git a/minifi_rust/minifi_native/src/mock/mock_controller_service_context.rs b/minifi_rust/minifi_native/src/mock/mock_controller_service_context.rs index 86a8a8158..581f12c22 100644 --- a/minifi_rust/minifi_native/src/mock/mock_controller_service_context.rs +++ b/minifi_rust/minifi_native/src/mock/mock_controller_service_context.rs @@ -24,9 +24,9 @@ pub struct MockControllerServiceContext { } impl GetProperty for MockControllerServiceContext { - fn get_raw_property<K: PropertySchema + ?Sized>( + fn get_raw_property<P: PropertySchema + ?Sized>( &self, - property: &Property<K>, + property: &Property<P>, ) -> Result<Option<String>, MinifiError> { self.properties.get_property(property, None) } diff --git a/minifi_rust/minifi_native/src/mock/mock_process_context.rs b/minifi_rust/minifi_native/src/mock/mock_process_context.rs index 56ba24236..580d7ceb8 100644 --- a/minifi_rust/minifi_native/src/mock/mock_process_context.rs +++ b/minifi_rust/minifi_native/src/mock/mock_process_context.rs @@ -55,9 +55,9 @@ impl MockPropertyMap { } impl MockPropertyMap { - pub fn get_property<K: PropertySchema + ?Sized>( + pub fn get_property<P: PropertySchema + ?Sized>( &self, - property: &Property<K>, + property: &Property<P>, _flow_file: Option<&MockFlowFile>, ) -> Result<Option<String>, MinifiError> { if let Some(value) = self.properties.get(property.name) { @@ -79,21 +79,21 @@ pub struct MockProcessContext { impl ProcessContext for MockProcessContext { type FlowFile = MockFlowFile; - fn get_raw_property<K: PropertySchema + ?Sized>( + fn get_raw_property<P: PropertySchema + ?Sized>( &self, - property: &Property<K>, + property: &Property<P>, _flow_file: Option<&Self::FlowFile>, ) -> Result<Option<String>, MinifiError> { self.properties.get_property(property, _flow_file) } - fn get_raw_controller_service<Cs, K>( + fn get_raw_controller_service<Cs, P>( &self, - property: &Property<K>, + property: &Property<P>, ) -> Result<Option<&Cs>, MinifiError> where Cs: RawControllerService + ComponentIdentifier + 'static, - K: PropertySchema + ?Sized, + P: PropertySchema + ?Sized, { // Mirror `get_controller_service`: resolve the property to a // service name and downcast the registered `Box<dyn Any>`.
