Skip to content

Commit e010490

Browse files
Merge pull request #92 from code0-tech/91-add-definition-reader
Definition Reader
2 parents c4cc75a + 330f066 commit e010490

File tree

14 files changed

+530
-188
lines changed

14 files changed

+530
-188
lines changed

Cargo.lock

Lines changed: 38 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,27 @@ homepage = "https://code0.tech"
88
license = "Apache-2.0"
99

1010
[dependencies]
11-
tucana = { version = "0.0.39", features = ["aquila"] }
11+
tucana = { version = "0.0.42", features = ["aquila"] }
1212
async-trait = "0.1.85"
1313
log = "0.4.24"
1414
tonic = "0.14.1"
1515
dotenv = "0.15.0"
16-
code0-definition-reader = "0.0.18"
1716
tonic-health = "0.14.1"
1817
async-nats = "0.45.0"
1918
futures-core = "0.3.31"
2019
regex = "1.11.2"
2120
serde_json = "1.0.143"
21+
walkdir = "2.5.0"
22+
serde = "1.0.228"
2223

2324
[lib]
2425
doctest = true
2526

2627
[features]
2728
default = ["all"]
2829
flow_definition = []
30+
flow_service = ["flow_definition"]
2931
flow_config = []
3032
flow_health = []
3133
flow_validator = []
32-
all = ["flow_definition", "flow_config", "flow_health", "flow_validator"]
34+
all = ["flow_definition", "flow_config", "flow_health", "flow_validator", "flow_service"]

src/flow_definition/error/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use std::io;
2+
use std::path::PathBuf;
3+
4+
#[derive(Debug)]
5+
pub enum ReaderError {
6+
JsonError {
7+
path: PathBuf,
8+
error: serde_json::Error,
9+
},
10+
ReadFeatureError {
11+
path: String,
12+
source: Box<ReaderError>,
13+
},
14+
ReadDirectoryError {
15+
path: PathBuf,
16+
error: io::Error,
17+
},
18+
ReadFileError {
19+
path: PathBuf,
20+
error: io::Error,
21+
},
22+
DirectoryEntryError(io::Error),
23+
}

src/flow_definition/feature/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
pub mod version;
2+
3+
use serde::Deserialize;
4+
use tucana::shared::{DefinitionDataType, FlowType, RuntimeFunctionDefinition};
5+
6+
#[derive(Deserialize, Debug, Clone)]
7+
pub struct Feature {
8+
pub name: String,
9+
pub data_types: Vec<DefinitionDataType>,
10+
pub flow_types: Vec<FlowType>,
11+
pub functions: Vec<RuntimeFunctionDefinition>,
12+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
use tucana::shared::{DefinitionDataType, FlowType, RuntimeFunctionDefinition, Version};
2+
3+
pub trait HasVersion {
4+
fn version(&self) -> &Option<Version>;
5+
fn version_mut(&mut self) -> &mut Option<Version>;
6+
7+
fn normalize_version(&mut self) {
8+
self.version_mut().get_or_insert(Version {
9+
major: 0,
10+
minor: 0,
11+
patch: 0,
12+
});
13+
}
14+
15+
fn is_accepted(&self, filter: &Option<Version>) -> bool {
16+
filter
17+
.as_ref()
18+
.is_none_or(|v| self.version().as_ref() == Some(v))
19+
}
20+
}
21+
22+
impl HasVersion for DefinitionDataType {
23+
fn version(&self) -> &Option<Version> {
24+
&self.version
25+
}
26+
27+
fn version_mut(&mut self) -> &mut Option<Version> {
28+
&mut self.version
29+
}
30+
}
31+
32+
impl HasVersion for FlowType {
33+
fn version(&self) -> &Option<Version> {
34+
&self.version
35+
}
36+
37+
fn version_mut(&mut self) -> &mut Option<Version> {
38+
&mut self.version
39+
}
40+
}
41+
42+
impl HasVersion for RuntimeFunctionDefinition {
43+
fn version(&self) -> &Option<Version> {
44+
&self.version
45+
}
46+
47+
fn version_mut(&mut self) -> &mut Option<Version> {
48+
&mut self.version
49+
}
50+
}

0 commit comments

Comments
 (0)