Skip to content

Commit 22469dd

Browse files
committed
feat: added reader to definition feature
1 parent 7af22c9 commit 22469dd

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

src/flow_definition/mod.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,39 @@ pub struct FlowUpdateService {
1616
}
1717

1818
impl FlowUpdateService {
19-
pub fn from_url(aquila_url: String) -> Self {
19+
/// Create a new FlowUpdateService instance from an Aquila URL and a definition path.
20+
///
21+
/// This will read the definition files from the given path and initialize the service with the data types, runtime definitions, and flow types.
22+
pub fn from_url(aquila_url: String, definition_path: &str) -> Self {
23+
let mut data_types = Vec::new();
24+
let mut runtime_definitions = Vec::new();
25+
let mut flow_types = Vec::new();
26+
27+
let definitions = match code0_definition_reader::parser::Parser::from_path(definition_path)
28+
{
29+
Some(reader) => reader,
30+
None => {
31+
log::error!("No definition folder found at path: {}", definition_path);
32+
return Self {
33+
aquila_url,
34+
data_types,
35+
runtime_definitions,
36+
flow_types,
37+
};
38+
}
39+
};
40+
41+
for feature in definitions.features {
42+
data_types.append(&mut feature.data_types.clone());
43+
flow_types.append(&mut feature.flow_types.clone());
44+
runtime_definitions.append(&mut feature.runtime_functions.clone());
45+
}
46+
2047
Self {
2148
aquila_url,
22-
data_types: Vec::new(),
23-
runtime_definitions: Vec::new(),
24-
flow_types: Vec::new(),
49+
data_types,
50+
runtime_definitions,
51+
flow_types,
2552
}
2653
}
2754

0 commit comments

Comments
 (0)