Skip to content

fix(deps): update rust crate tucana to 0.0.31 #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2025
Merged
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ homepage = "https://code0.tech"
license = "Apache-2.0"

[dependencies]
tucana = { version = "0.0.28", features = ["aquila"] }
tucana = { version = "0.0.31", features = ["aquila"] }
tokio = "1.43.0"
async-trait = "0.1.85"
log = "0.4.24"
Expand Down
2 changes: 1 addition & 1 deletion src/flow_definition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tucana::{
flow_type_service_client::FlowTypeServiceClient,
runtime_function_definition_service_client::RuntimeFunctionDefinitionServiceClient,
},
shared::{DataType, FlowType, RuntimeFunctionDefinition},
shared::{DefinitionDataType as DataType, FlowType, RuntimeFunctionDefinition},
};

pub struct FlowUpdateService {
Expand Down
21 changes: 8 additions & 13 deletions src/flow_store/flow_identifier.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use tucana::shared::{Flow, FlowSetting, value::Kind};
use tucana::shared::{FlowSetting, ValidationFlow, value::Kind};

fn extract_field(settings: &[FlowSetting], def_key: &str, field_name: &str) -> Option<String> {
settings.iter().find_map(|setting| {
let def = setting.definition.as_ref()?;
if def.key != def_key {
if setting.flow_setting_id != def_key {
return None;
}

Expand All @@ -21,7 +20,7 @@ fn extract_field(settings: &[FlowSetting], def_key: &str, field_name: &str) -> O

/// Every flow identifier needs to start with its
/// flow_id::project_id::flow_identifier::protocol_specific_fields
pub fn get_flow_identifier(flow: &Flow) -> Option<String> {
pub fn get_flow_identifier(flow: &ValidationFlow) -> Option<String> {
match flow.r#type.as_str() {
"REST" => {
let method = extract_field(&flow.settings, "HTTP_METHOD", "method");
Expand All @@ -48,7 +47,7 @@ pub fn get_flow_identifier(flow: &Flow) -> Option<String> {
mod test {
use std::collections::HashMap;

use tucana::shared::{Flow, FlowSetting, FlowSettingDefinition, Struct};
use tucana::shared::{FlowSetting, Struct, ValidationFlow as Flow};

use super::get_flow_identifier;

Expand Down Expand Up @@ -88,10 +87,8 @@ mod test {
return_type_identifier: None,
settings: vec![
FlowSetting {
definition: Some(FlowSettingDefinition {
id: String::from("1424525"),
key: String::from("HTTP_HOST"),
}),
database_id: 1424525,
flow_setting_id: String::from("HTTP_HOST"),
object: Some(Struct {
fields: {
let mut map = HashMap::new();
Expand All @@ -101,10 +98,8 @@ mod test {
}),
},
FlowSetting {
definition: Some(FlowSettingDefinition {
id: String::from("14245252352"),
key: String::from("HTTP_METHOD"),
}),
database_id: 14245252352,
flow_setting_id: String::from("HTTP_METHOD"),
object: Some(Struct {
fields: {
let mut map = HashMap::new();
Expand Down
74 changes: 35 additions & 39 deletions src/flow_store/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::flow_store::connection::FlowStore;
use async_trait::async_trait;
use log::error;
use redis::{AsyncCommands, JsonAsyncCommands, RedisError, RedisResult};
use tucana::shared::{Flow, Flows};
use tucana::shared::{Flows, ValidationFlow};

#[derive(Debug)]
pub struct FlowStoreError {
Expand All @@ -23,7 +23,7 @@ pub enum FlowStoreErrorKind {
#[async_trait]
pub trait FlowStoreServiceBase {
async fn new(redis_client_arc: FlowStore) -> Self;
async fn insert_flow(&mut self, flow: Flow) -> Result<i64, FlowStoreError>;
async fn insert_flow(&mut self, flow: ValidationFlow) -> Result<i64, FlowStoreError>;
async fn insert_flows(&mut self, flows: Flows) -> Result<i64, FlowStoreError>;
async fn delete_flow(&mut self, flow_id: i64) -> Result<i64, RedisError>;
async fn delete_flows(&mut self, flow_ids: Vec<i64>) -> Result<i64, RedisError>;
Expand All @@ -45,7 +45,7 @@ impl FlowStoreServiceBase for FlowStoreService {
}

/// Insert a list of flows into Redis
async fn insert_flow(&mut self, flow: Flow) -> Result<i64, FlowStoreError> {
async fn insert_flow(&mut self, flow: ValidationFlow) -> Result<i64, FlowStoreError> {
let mut connection = self.redis_client_arc.lock().await;

let identifier = match flow_identifier::get_flow_identifier(&flow) {
Expand Down Expand Up @@ -175,10 +175,10 @@ impl FlowStoreServiceBase for FlowStoreService {
.await
{
Ok(json_values) => {
let mut all_flows: Vec<Flow> = Vec::new();
let mut all_flows: Vec<ValidationFlow> = Vec::new();

for json_str in json_values {
match serde_json::from_str::<Vec<Flow>>(&json_str) {
match serde_json::from_str::<Vec<ValidationFlow>>(&json_str) {
Ok(mut flows) => all_flows.append(&mut flows),
Err(error) => {
return Err(FlowStoreError {
Expand Down Expand Up @@ -207,20 +207,19 @@ impl FlowStoreServiceBase for FlowStoreService {
mod tests {
use std::collections::HashMap;

use crate::flow_store::connection::create_flow_store_connection;
use crate::flow_store::connection::FlowStore;
use crate::flow_store::connection::create_flow_store_connection;
use crate::flow_store::service::FlowStoreService;
use crate::flow_store::service::FlowStoreServiceBase;
use redis::{AsyncCommands, JsonAsyncCommands};
use serial_test::serial;
use testcontainers::GenericImage;
use testcontainers::core::IntoContainerPort;
use testcontainers::core::WaitFor;
use testcontainers::runners::AsyncRunner;
use testcontainers::GenericImage;
use tucana::shared::FlowSetting;
use tucana::shared::FlowSettingDefinition;
use tucana::shared::Struct;
use tucana::shared::{Flow, Flows};
use tucana::shared::{Flows, ValidationFlow};

fn get_string_value(value: &str) -> tucana::shared::Value {
tucana::shared::Value {
Expand All @@ -233,10 +232,8 @@ mod tests {
fn get_settings() -> Vec<FlowSetting> {
vec![
FlowSetting {
definition: Some(FlowSettingDefinition {
id: String::from("1424525"),
key: String::from("HTTP_HOST"),
}),
database_id: 1234567,
flow_setting_id: String::from("HTTP_HOST"),
object: Some(Struct {
fields: {
let mut map = HashMap::new();
Expand All @@ -246,10 +243,8 @@ mod tests {
}),
},
FlowSetting {
definition: Some(FlowSettingDefinition {
id: String::from("14245252352"),
key: String::from("HTTP_METHOD"),
}),
database_id: 14245252352,
flow_setting_id: String::from("HTTP_METHOD"),
object: Some(Struct {
fields: {
let mut map = HashMap::new();
Expand Down Expand Up @@ -304,7 +299,7 @@ mod tests {
redis_integration_test!(
insert_one_flow,
(|connection: FlowStore, mut service: FlowStoreService| async move {
let flow = Flow {
let flow = ValidationFlow {
flow_id: 1,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -331,15 +326,16 @@ mod tests {
println!("{}", redis_result.clone().unwrap());

assert!(redis_result.is_some());
let redis_flow: Vec<Flow> = serde_json::from_str(&*redis_result.unwrap()).unwrap();
let redis_flow: Vec<ValidationFlow> =
serde_json::from_str(&*redis_result.unwrap()).unwrap();
assert_eq!(redis_flow[0], flow);
})
);

redis_integration_test!(
insert_one_flow_fails_no_identifier,
(|_connection: FlowStore, mut service: FlowStoreService| async move {
let flow = Flow {
let flow = ValidationFlow {
flow_id: 1,
r#type: "".to_string(),
settings: get_settings(),
Expand All @@ -357,7 +353,7 @@ mod tests {
redis_integration_test!(
insert_will_overwrite_existing_flow,
(|connection: FlowStore, mut service: FlowStoreService| async move {
let flow = Flow {
let flow = ValidationFlow {
flow_id: 1,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -373,7 +369,7 @@ mod tests {
Err(err) => println!("{}", err.reason),
};

let flow_overwrite = Flow {
let flow_overwrite = ValidationFlow {
flow_id: 1,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -398,15 +394,15 @@ mod tests {

assert_eq!(redis_result.len(), 1);
let string: &str = &*redis_result[0];
let redis_flow: Vec<Flow> = serde_json::from_str(string).unwrap();
let redis_flow: Vec<ValidationFlow> = serde_json::from_str(string).unwrap();
assert!(redis_flow[0].r#input_type_identifier.is_some());
})
);

redis_integration_test!(
insert_many_flows,
(|_connection: FlowStore, mut service: FlowStoreService| async move {
let flow_one = Flow {
let flow_one = ValidationFlow {
flow_id: 1,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -417,7 +413,7 @@ mod tests {
starting_node: None,
};

let flow_two = Flow {
let flow_two = ValidationFlow {
flow_id: 2,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -428,7 +424,7 @@ mod tests {
starting_node: None,
};

let flow_three = Flow {
let flow_three = ValidationFlow {
flow_id: 3,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -450,7 +446,7 @@ mod tests {
redis_integration_test!(
delete_one_existing_flow,
(|connection: FlowStore, mut service: FlowStoreService| async move {
let flow = Flow {
let flow = ValidationFlow {
flow_id: 1,
r#type: "REST".to_string(),
settings: get_settings(),
Expand Down Expand Up @@ -490,7 +486,7 @@ mod tests {
redis_integration_test!(
delete_many_existing_flows,
(|_connection: FlowStore, mut service: FlowStoreService| async move {
let flow_one = Flow {
let flow_one = ValidationFlow {
flow_id: 1,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -501,7 +497,7 @@ mod tests {
project_id: 1,
};

let flow_two = Flow {
let flow_two = ValidationFlow {
flow_id: 2,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -512,7 +508,7 @@ mod tests {
project_id: 1,
};

let flow_three = Flow {
let flow_three = ValidationFlow {
flow_id: 3,
r#type: "REST".to_string(),
settings: get_settings(),
Expand Down Expand Up @@ -545,7 +541,7 @@ mod tests {
redis_integration_test!(
get_existing_flow_ids,
(|_connection: FlowStore, mut service: FlowStoreService| async move {
let flow_one = Flow {
let flow_one = ValidationFlow {
flow_id: 1,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -556,7 +552,7 @@ mod tests {
project_id: 1,
};

let flow_two = Flow {
let flow_two = ValidationFlow {
flow_id: 2,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -567,7 +563,7 @@ mod tests {
project_id: 1,
};

let flow_three = Flow {
let flow_three = ValidationFlow {
flow_id: 3,
r#type: "REST".to_string(),
settings: get_settings(),
Expand Down Expand Up @@ -611,7 +607,7 @@ mod tests {
redis_integration_test!(
query_all_flows,
(|_connection: FlowStore, mut service: FlowStoreService| async move {
let flow_one = Flow {
let flow_one = ValidationFlow {
flow_id: 1,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -622,7 +618,7 @@ mod tests {
project_id: 1,
};

let flow_two = Flow {
let flow_two = ValidationFlow {
flow_id: 2,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -633,7 +629,7 @@ mod tests {
project_id: 1,
};

let flow_three = Flow {
let flow_three = ValidationFlow {
flow_id: 3,
r#type: "REST".to_string(),
settings: get_settings(),
Expand Down Expand Up @@ -667,7 +663,7 @@ mod tests {
redis_integration_test!(
query_one_existing_flow,
(|_connection: FlowStore, mut service: FlowStoreService| async move {
let flow_one = Flow {
let flow_one = ValidationFlow {
flow_id: 1,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -678,7 +674,7 @@ mod tests {
project_id: 1,
};

let flow_two = Flow {
let flow_two = ValidationFlow {
flow_id: 2,
r#type: "REST".to_string(),
settings: get_settings(),
Expand All @@ -689,7 +685,7 @@ mod tests {
project_id: 1,
};

let flow_three = Flow {
let flow_three = ValidationFlow {
flow_id: 3,
r#type: "REST".to_string(),
settings: get_settings(),
Expand Down