Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/references/ubuntu_22_04_clang_arm_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4069,7 +4069,7 @@
"name": "Keep Source File",
"description": "If true, the file is not deleted after it has been copied to the Content Repository",
"validator": "BOOLEAN_VALIDATOR",
"required": "false",
"required": "true",
"sensitive": "false",
"expressionLanguageScope": "NONE",
"defaultValue": "false"
Expand Down Expand Up @@ -4118,7 +4118,7 @@
"name": "Recurse Subdirectories",
"description": "Indicates whether or not to pull files from subdirectories",
"validator": "BOOLEAN_VALIDATOR",
"required": "false",
"required": "true",
"sensitive": "false",
"expressionLanguageScope": "NONE",
"defaultValue": "true"
Expand Down Expand Up @@ -6345,7 +6345,7 @@
"FlowFiles To Log": {
"name": "FlowFiles To Log",
"description": "Number of flow files to log. If set to zero all flow files will be logged. Please note that this may block other threads from running if not used judiciously.",
"validator": "VALID",
"validator": "NON_NEGATIVE_INTEGER_VALIDATOR",
"required": "true",
"sensitive": "false",
"expressionLanguageScope": "NONE",
Expand Down
1 change: 1 addition & 0 deletions minifi_rust/extensions/minifi_rs_playground/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ hex = "0.4.3"
strum_macros = "0.28.0"
lipsum = "0.9.1"


[dev-dependencies]
tempfile = "3.22.0"
filetime = "0.2.26"
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
use crate::controller_services::animal_controller_apis::{
CanFlyControllerApi, NumberOfLegsControllerApi,
};
use minifi_native::ControllerServiceApi;
use minifi_native::macros::ComponentIdentifier;
use minifi_native::{ControllerServiceApi, property_constraint};
use minifi_native::{
ControllerServiceDefinition, EnableControllerService, GetProperty, Logger, MinifiError,
Property, ProvidedInterface, StandardPropertyValidator, create_provided_interface,
Property, ProvidedInterface, create_provided_interface,
};

pub(crate) const HAS_JETPACK: Property = Property {
Expand All @@ -32,9 +32,7 @@ pub(crate) const HAS_JETPACK: Property = Property {
is_sensitive: false,
supports_expr_lang: false,
default_value: Some("false"),
validator: StandardPropertyValidator::BoolValidator,
allowed_values: &[],
allowed_type: None,
constraints: property_constraint::<bool>(),

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.

After our private discussion, I'll wait to see if you can refactor this to move the type to a Property type parameter, but the current version is an improvement too.

};

pub(crate) const EXTRA_INFO: Property = Property {
Expand All @@ -44,9 +42,7 @@ pub(crate) const EXTRA_INFO: Property = Property {
is_sensitive: false,
supports_expr_lang: false,
default_value: None,
validator: StandardPropertyValidator::AlwaysValidValidator,
allowed_values: &[],
allowed_type: None,
constraints: None,
};

#[allow(dead_code)] // extra_info is only used by {:?}
Expand All @@ -73,11 +69,10 @@ impl EnableControllerService for DogControllerRs {
where
Self: Sized,
{
let has_jetpack = context.get_bool_property(&HAS_JETPACK)?.ok_or(
MinifiError::missing_required_property("Has jetpack is required"),
)?;

let extra_info = context.get_property(&EXTRA_INFO)?.unwrap_or("".into());
let has_jetpack = context.get_req_property::<bool>(&HAS_JETPACK)?;
let extra_info = context
.get_property::<String>(&EXTRA_INFO)?
.unwrap_or("".into());

Ok(Self {
has_jetpack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use lipsum::lipsum;
use minifi_native::macros::ComponentIdentifier;
use minifi_native::{
ControllerServiceDefinition, EnableControllerService, GetProperty, Logger, MinifiError,
Property, ProvidedInterface, StandardPropertyValidator,
Property, ProvidedInterface, property_constraint,
};

const LENGTH: Property = Property {
Expand All @@ -29,9 +29,7 @@ const LENGTH: Property = Property {
is_sensitive: false,
supports_expr_lang: false,
default_value: Some("25"),
validator: StandardPropertyValidator::U64Validator,
allowed_values: &[],
allowed_type: None,
constraints: property_constraint::<u64>(),
};

#[derive(Debug, ComponentIdentifier)]
Expand All @@ -44,11 +42,7 @@ impl EnableControllerService for LoremIpsumControllerService {
where
Self: Sized,
{
let length = context
.get_u64_property(&LENGTH)?
.ok_or(MinifiError::missing_required_property("Length is required"))?;

let data = lipsum(length as usize);
let data = lipsum(context.get_req_property::<usize>(&LENGTH)?);
Ok(Self { data })
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

use minifi_native::macros::ComponentIdentifier;
use minifi_native::{
GetProperty, Logger, MinifiError, OnTriggerResult, ProcessContext, ProcessSession, Schedule,
Trigger,
DataSize, GetProperty, Logger, MinifiError, OnTriggerResult, ProcessContext, ProcessSession,
Schedule, Trigger,
};
use rand::RngExt;
use rand::distr::Alphanumeric;
Expand Down Expand Up @@ -52,22 +52,14 @@ impl Schedule for GenerateFlowFileRs {
where
Self: Sized,
{
let is_unique = context
.get_bool_property(&properties::UNIQUE_FLOW_FILES)?
.expect("Required property");
let is_text = context
.get_property(&properties::DATA_FORMAT)?
.expect("Required property")
.as_str()
== "Text";
let has_custom_text = context.get_property(&properties::CUSTOM_TEXT)?.is_some();

let file_size = context
.get_size_property(&properties::FILE_SIZE)?
.expect("Required property");
let batch_size = context
.get_u64_property(&properties::BATCH_SIZE)?
.expect("Required property");
let is_unique = context.get_req_property::<bool>(&properties::UNIQUE_FLOW_FILES)?;
let is_text = context.get_req_property::<String>(&properties::DATA_FORMAT)? == "Text";
let has_custom_text = context
.get_property::<String>(&properties::CUSTOM_TEXT)?
.is_some();

let file_size = context.get_req_property::<DataSize>(&properties::FILE_SIZE)?;
let batch_size = context.get_req_property::<u64>(&properties::BATCH_SIZE)?;

let mode = Self::get_mode(is_unique, is_text, has_custom_text, file_size);
let data_generated_during_on_schedule =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.

use minifi_native::{Property, StandardPropertyValidator};
use minifi_native::PropertyConstraints::AllowedValues;
use minifi_native::{DataSize, Property, property_constraint};

pub(crate) const FILE_SIZE: Property = Property {
name: "File Size",
Expand All @@ -24,9 +25,7 @@ pub(crate) const FILE_SIZE: Property = Property {
is_sensitive: false,
supports_expr_lang: true,
default_value: Some("1 kB"),
validator: StandardPropertyValidator::DataSizeValidator,
allowed_values: &[],
allowed_type: None,
constraints: property_constraint::<DataSize>(),
};

pub(crate) const BATCH_SIZE: Property = Property {
Expand All @@ -36,9 +35,7 @@ pub(crate) const BATCH_SIZE: Property = Property {
is_sensitive: false,
supports_expr_lang: false,
default_value: Some("1"),
validator: StandardPropertyValidator::U64Validator,
allowed_values: &[],
allowed_type: None,
constraints: property_constraint::<u64>(),
};

pub(crate) const DATA_FORMAT: Property = Property {
Expand All @@ -48,9 +45,7 @@ pub(crate) const DATA_FORMAT: Property = Property {
is_sensitive: false,
supports_expr_lang: false,
default_value: Some("Binary"),
validator: StandardPropertyValidator::AlwaysValidValidator,
allowed_values: &["Text", "Binary"],
allowed_type: None,
constraints: Some(AllowedValues(&["Text", "Binary"])),
};

pub(crate) const UNIQUE_FLOW_FILES: Property = Property {
Expand All @@ -60,9 +55,7 @@ pub(crate) const UNIQUE_FLOW_FILES: Property = Property {
is_sensitive: false,
supports_expr_lang: false,
default_value: Some("true"),
validator: StandardPropertyValidator::BoolValidator,
allowed_values: &[],
allowed_type: None,
constraints: property_constraint::<bool>(),
};

pub(crate) const CUSTOM_TEXT: Property = Property {
Expand All @@ -72,7 +65,5 @@ pub(crate) const CUSTOM_TEXT: Property = Property {
is_sensitive: false,
supports_expr_lang: true,
default_value: None,
validator: StandardPropertyValidator::AlwaysValidValidator,
allowed_values: &[],
allowed_type: None,
constraints: None,
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use crate::processors::get_file::properties::{
};
use minifi_native::macros::ComponentIdentifier;
use minifi_native::{
GetProperty, IoState, Logger, MinifiError, OnTriggerResult, ProcessContext, ProcessSession,
Schedule, Trigger, debug, info, trace, warn,
DataSize, GetProperty, IoState, Logger, MinifiError, OnTriggerResult, ProcessContext,
ProcessSession, Schedule, Trigger, debug, info, trace, warn,
};
use std::collections::VecDeque;
use std::error;
Expand Down Expand Up @@ -223,36 +223,25 @@ impl Schedule for GetFileRs {
where
Self: Sized,
{
let input_directory: PathBuf = context
.get_property(&DIRECTORY)?
.expect("Required property")
.into();
let input_directory = context.get_req_property::<PathBuf>(&DIRECTORY)?;
if !input_directory.is_dir() {
return Err(MinifiError::schedule_err(format!(
"{:?} is not a valid directory",
input_directory
)));
}

let recursive = context
.get_bool_property(&RECURSE)?
.expect("Required property");

let keep_source_file = context
.get_bool_property(&KEEP_SOURCE_FILE)?
.expect("Required property");

let poll_interval = context.get_duration_property(&properties::POLLING_INTERVAL)?;
let min_size = context.get_size_property(&MIN_SIZE)?;
let max_size = context.get_size_property(&MAX_SIZE)?;
let min_age = context.get_duration_property(&MIN_AGE)?;
let max_age = context.get_duration_property(&MAX_AGE)?;
let batch_size = context
.get_u64_property(&BATCH_SIZE)?
.expect("required property");
let ignore_hidden_files = context
.get_bool_property(&IGNORE_HIDDEN_FILES)?
.expect("required property");
let recursive = context.get_req_property::<bool>(&RECURSE)?;

let keep_source_file = context.get_req_property::<bool>(&KEEP_SOURCE_FILE)?;

let poll_interval = context.get_property::<Duration>(&properties::POLLING_INTERVAL)?;
let min_size = context.get_property::<DataSize>(&MIN_SIZE)?;
let max_size = context.get_property::<DataSize>(&MAX_SIZE)?;
let min_age = context.get_property::<Duration>(&MIN_AGE)?;
let max_age = context.get_property::<Duration>(&MAX_AGE)?;
let batch_size = context.get_req_property::<u64>(&BATCH_SIZE)?;
let ignore_hidden_files = context.get_req_property::<bool>(&IGNORE_HIDDEN_FILES)?;

Ok(GetFileRs {
recursive,
Expand Down
Loading
Loading