From 6f8e4d10a9eeef35c7c6add6a9f1a5bc46a5054a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 17:10:48 +0000 Subject: [PATCH 1/2] fix(deps): update rust crate tucana to 0.0.31 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 478c084..201d15e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3095,9 +3095,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tucana" -version = "0.0.28" +version = "0.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db7694d43cff47f6464cf502b67f7f5c6da1b1e05f0693dda755e5eff8deeeaa" +checksum = "d3338717f8c96cf6b4fb87cc5b41e70f2cd6ab3c1e0148f1bd48ea1a5f5000bf" dependencies = [ "prost", "prost-types", diff --git a/Cargo.toml b/Cargo.toml index 6ff7080..915402c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" From bd0d626f1a0bf184d929dbfe00c52c89d43d657b Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 8 Jun 2025 12:24:19 +0200 Subject: [PATCH 2/2] feat: adjusted to new tucana changes --- src/flow_definition/mod.rs | 2 +- src/flow_store/flow_identifier.rs | 21 ++++----- src/flow_store/service.rs | 74 +++++++++++++++---------------- 3 files changed, 44 insertions(+), 53 deletions(-) diff --git a/src/flow_definition/mod.rs b/src/flow_definition/mod.rs index 308839f..6ce5183 100644 --- a/src/flow_definition/mod.rs +++ b/src/flow_definition/mod.rs @@ -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 { diff --git a/src/flow_store/flow_identifier.rs b/src/flow_store/flow_identifier.rs index 595d98d..ed46974 100644 --- a/src/flow_store/flow_identifier.rs +++ b/src/flow_store/flow_identifier.rs @@ -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 { 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; } @@ -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 { +pub fn get_flow_identifier(flow: &ValidationFlow) -> Option { match flow.r#type.as_str() { "REST" => { let method = extract_field(&flow.settings, "HTTP_METHOD", "method"); @@ -48,7 +47,7 @@ pub fn get_flow_identifier(flow: &Flow) -> Option { 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; @@ -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(); @@ -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(); diff --git a/src/flow_store/service.rs b/src/flow_store/service.rs index 035afa6..a4b91c6 100644 --- a/src/flow_store/service.rs +++ b/src/flow_store/service.rs @@ -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 { @@ -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; + async fn insert_flow(&mut self, flow: ValidationFlow) -> Result; async fn insert_flows(&mut self, flows: Flows) -> Result; async fn delete_flow(&mut self, flow_id: i64) -> Result; async fn delete_flows(&mut self, flow_ids: Vec) -> Result; @@ -45,7 +45,7 @@ impl FlowStoreServiceBase for FlowStoreService { } /// Insert a list of flows into Redis - async fn insert_flow(&mut self, flow: Flow) -> Result { + async fn insert_flow(&mut self, flow: ValidationFlow) -> Result { let mut connection = self.redis_client_arc.lock().await; let identifier = match flow_identifier::get_flow_identifier(&flow) { @@ -175,10 +175,10 @@ impl FlowStoreServiceBase for FlowStoreService { .await { Ok(json_values) => { - let mut all_flows: Vec = Vec::new(); + let mut all_flows: Vec = Vec::new(); for json_str in json_values { - match serde_json::from_str::>(&json_str) { + match serde_json::from_str::>(&json_str) { Ok(mut flows) => all_flows.append(&mut flows), Err(error) => { return Err(FlowStoreError { @@ -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 { @@ -233,10 +232,8 @@ mod tests { fn get_settings() -> Vec { 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(); @@ -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(); @@ -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(), @@ -331,7 +326,8 @@ mod tests { println!("{}", redis_result.clone().unwrap()); assert!(redis_result.is_some()); - let redis_flow: Vec = serde_json::from_str(&*redis_result.unwrap()).unwrap(); + let redis_flow: Vec = + serde_json::from_str(&*redis_result.unwrap()).unwrap(); assert_eq!(redis_flow[0], flow); }) ); @@ -339,7 +335,7 @@ mod tests { 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(), @@ -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(), @@ -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(), @@ -398,7 +394,7 @@ mod tests { assert_eq!(redis_result.len(), 1); let string: &str = &*redis_result[0]; - let redis_flow: Vec = serde_json::from_str(string).unwrap(); + let redis_flow: Vec = serde_json::from_str(string).unwrap(); assert!(redis_flow[0].r#input_type_identifier.is_some()); }) ); @@ -406,7 +402,7 @@ mod tests { 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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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(),