Skip to content

Commit 1d558e8

Browse files
Merge pull request #43 from code0-tech/renovate/tucana-0.x
fix(deps): update rust crate tucana to 0.0.31
2 parents 9e1b0c5 + bd0d626 commit 1d558e8

File tree

5 files changed

+47
-56
lines changed

5 files changed

+47
-56
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ homepage = "https://code0.tech"
88
license = "Apache-2.0"
99

1010
[dependencies]
11-
tucana = { version = "0.0.28", features = ["aquila"] }
11+
tucana = { version = "0.0.31", features = ["aquila"] }
1212
tokio = "1.43.0"
1313
async-trait = "0.1.85"
1414
log = "0.4.24"

src/flow_definition/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tucana::{
55
flow_type_service_client::FlowTypeServiceClient,
66
runtime_function_definition_service_client::RuntimeFunctionDefinitionServiceClient,
77
},
8-
shared::{DataType, FlowType, RuntimeFunctionDefinition},
8+
shared::{DefinitionDataType as DataType, FlowType, RuntimeFunctionDefinition},
99
};
1010

1111
pub struct FlowUpdateService {

src/flow_store/flow_identifier.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use tucana::shared::{Flow, FlowSetting, value::Kind};
1+
use tucana::shared::{FlowSetting, ValidationFlow, value::Kind};
22

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

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

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

51-
use tucana::shared::{Flow, FlowSetting, FlowSettingDefinition, Struct};
50+
use tucana::shared::{FlowSetting, Struct, ValidationFlow as Flow};
5251

5352
use super::get_flow_identifier;
5453

@@ -88,10 +87,8 @@ mod test {
8887
return_type_identifier: None,
8988
settings: vec![
9089
FlowSetting {
91-
definition: Some(FlowSettingDefinition {
92-
id: String::from("1424525"),
93-
key: String::from("HTTP_HOST"),
94-
}),
90+
database_id: 1424525,
91+
flow_setting_id: String::from("HTTP_HOST"),
9592
object: Some(Struct {
9693
fields: {
9794
let mut map = HashMap::new();
@@ -101,10 +98,8 @@ mod test {
10198
}),
10299
},
103100
FlowSetting {
104-
definition: Some(FlowSettingDefinition {
105-
id: String::from("14245252352"),
106-
key: String::from("HTTP_METHOD"),
107-
}),
101+
database_id: 14245252352,
102+
flow_setting_id: String::from("HTTP_METHOD"),
108103
object: Some(Struct {
109104
fields: {
110105
let mut map = HashMap::new();

src/flow_store/service.rs

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::flow_store::connection::FlowStore;
33
use async_trait::async_trait;
44
use log::error;
55
use redis::{AsyncCommands, JsonAsyncCommands, RedisError, RedisResult};
6-
use tucana::shared::{Flow, Flows};
6+
use tucana::shared::{Flows, ValidationFlow};
77

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

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

5151
let identifier = match flow_identifier::get_flow_identifier(&flow) {
@@ -175,10 +175,10 @@ impl FlowStoreServiceBase for FlowStoreService {
175175
.await
176176
{
177177
Ok(json_values) => {
178-
let mut all_flows: Vec<Flow> = Vec::new();
178+
let mut all_flows: Vec<ValidationFlow> = Vec::new();
179179

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

210-
use crate::flow_store::connection::create_flow_store_connection;
211210
use crate::flow_store::connection::FlowStore;
211+
use crate::flow_store::connection::create_flow_store_connection;
212212
use crate::flow_store::service::FlowStoreService;
213213
use crate::flow_store::service::FlowStoreServiceBase;
214214
use redis::{AsyncCommands, JsonAsyncCommands};
215215
use serial_test::serial;
216+
use testcontainers::GenericImage;
216217
use testcontainers::core::IntoContainerPort;
217218
use testcontainers::core::WaitFor;
218219
use testcontainers::runners::AsyncRunner;
219-
use testcontainers::GenericImage;
220220
use tucana::shared::FlowSetting;
221-
use tucana::shared::FlowSettingDefinition;
222221
use tucana::shared::Struct;
223-
use tucana::shared::{Flow, Flows};
222+
use tucana::shared::{Flows, ValidationFlow};
224223

225224
fn get_string_value(value: &str) -> tucana::shared::Value {
226225
tucana::shared::Value {
@@ -233,10 +232,8 @@ mod tests {
233232
fn get_settings() -> Vec<FlowSetting> {
234233
vec![
235234
FlowSetting {
236-
definition: Some(FlowSettingDefinition {
237-
id: String::from("1424525"),
238-
key: String::from("HTTP_HOST"),
239-
}),
235+
database_id: 1234567,
236+
flow_setting_id: String::from("HTTP_HOST"),
240237
object: Some(Struct {
241238
fields: {
242239
let mut map = HashMap::new();
@@ -246,10 +243,8 @@ mod tests {
246243
}),
247244
},
248245
FlowSetting {
249-
definition: Some(FlowSettingDefinition {
250-
id: String::from("14245252352"),
251-
key: String::from("HTTP_METHOD"),
252-
}),
246+
database_id: 14245252352,
247+
flow_setting_id: String::from("HTTP_METHOD"),
253248
object: Some(Struct {
254249
fields: {
255250
let mut map = HashMap::new();
@@ -304,7 +299,7 @@ mod tests {
304299
redis_integration_test!(
305300
insert_one_flow,
306301
(|connection: FlowStore, mut service: FlowStoreService| async move {
307-
let flow = Flow {
302+
let flow = ValidationFlow {
308303
flow_id: 1,
309304
r#type: "REST".to_string(),
310305
settings: get_settings(),
@@ -331,15 +326,16 @@ mod tests {
331326
println!("{}", redis_result.clone().unwrap());
332327

333328
assert!(redis_result.is_some());
334-
let redis_flow: Vec<Flow> = serde_json::from_str(&*redis_result.unwrap()).unwrap();
329+
let redis_flow: Vec<ValidationFlow> =
330+
serde_json::from_str(&*redis_result.unwrap()).unwrap();
335331
assert_eq!(redis_flow[0], flow);
336332
})
337333
);
338334

339335
redis_integration_test!(
340336
insert_one_flow_fails_no_identifier,
341337
(|_connection: FlowStore, mut service: FlowStoreService| async move {
342-
let flow = Flow {
338+
let flow = ValidationFlow {
343339
flow_id: 1,
344340
r#type: "".to_string(),
345341
settings: get_settings(),
@@ -357,7 +353,7 @@ mod tests {
357353
redis_integration_test!(
358354
insert_will_overwrite_existing_flow,
359355
(|connection: FlowStore, mut service: FlowStoreService| async move {
360-
let flow = Flow {
356+
let flow = ValidationFlow {
361357
flow_id: 1,
362358
r#type: "REST".to_string(),
363359
settings: get_settings(),
@@ -373,7 +369,7 @@ mod tests {
373369
Err(err) => println!("{}", err.reason),
374370
};
375371

376-
let flow_overwrite = Flow {
372+
let flow_overwrite = ValidationFlow {
377373
flow_id: 1,
378374
r#type: "REST".to_string(),
379375
settings: get_settings(),
@@ -398,15 +394,15 @@ mod tests {
398394

399395
assert_eq!(redis_result.len(), 1);
400396
let string: &str = &*redis_result[0];
401-
let redis_flow: Vec<Flow> = serde_json::from_str(string).unwrap();
397+
let redis_flow: Vec<ValidationFlow> = serde_json::from_str(string).unwrap();
402398
assert!(redis_flow[0].r#input_type_identifier.is_some());
403399
})
404400
);
405401

406402
redis_integration_test!(
407403
insert_many_flows,
408404
(|_connection: FlowStore, mut service: FlowStoreService| async move {
409-
let flow_one = Flow {
405+
let flow_one = ValidationFlow {
410406
flow_id: 1,
411407
r#type: "REST".to_string(),
412408
settings: get_settings(),
@@ -417,7 +413,7 @@ mod tests {
417413
starting_node: None,
418414
};
419415

420-
let flow_two = Flow {
416+
let flow_two = ValidationFlow {
421417
flow_id: 2,
422418
r#type: "REST".to_string(),
423419
settings: get_settings(),
@@ -428,7 +424,7 @@ mod tests {
428424
starting_node: None,
429425
};
430426

431-
let flow_three = Flow {
427+
let flow_three = ValidationFlow {
432428
flow_id: 3,
433429
r#type: "REST".to_string(),
434430
settings: get_settings(),
@@ -450,7 +446,7 @@ mod tests {
450446
redis_integration_test!(
451447
delete_one_existing_flow,
452448
(|connection: FlowStore, mut service: FlowStoreService| async move {
453-
let flow = Flow {
449+
let flow = ValidationFlow {
454450
flow_id: 1,
455451
r#type: "REST".to_string(),
456452
settings: get_settings(),
@@ -490,7 +486,7 @@ mod tests {
490486
redis_integration_test!(
491487
delete_many_existing_flows,
492488
(|_connection: FlowStore, mut service: FlowStoreService| async move {
493-
let flow_one = Flow {
489+
let flow_one = ValidationFlow {
494490
flow_id: 1,
495491
r#type: "REST".to_string(),
496492
settings: get_settings(),
@@ -501,7 +497,7 @@ mod tests {
501497
project_id: 1,
502498
};
503499

504-
let flow_two = Flow {
500+
let flow_two = ValidationFlow {
505501
flow_id: 2,
506502
r#type: "REST".to_string(),
507503
settings: get_settings(),
@@ -512,7 +508,7 @@ mod tests {
512508
project_id: 1,
513509
};
514510

515-
let flow_three = Flow {
511+
let flow_three = ValidationFlow {
516512
flow_id: 3,
517513
r#type: "REST".to_string(),
518514
settings: get_settings(),
@@ -545,7 +541,7 @@ mod tests {
545541
redis_integration_test!(
546542
get_existing_flow_ids,
547543
(|_connection: FlowStore, mut service: FlowStoreService| async move {
548-
let flow_one = Flow {
544+
let flow_one = ValidationFlow {
549545
flow_id: 1,
550546
r#type: "REST".to_string(),
551547
settings: get_settings(),
@@ -556,7 +552,7 @@ mod tests {
556552
project_id: 1,
557553
};
558554

559-
let flow_two = Flow {
555+
let flow_two = ValidationFlow {
560556
flow_id: 2,
561557
r#type: "REST".to_string(),
562558
settings: get_settings(),
@@ -567,7 +563,7 @@ mod tests {
567563
project_id: 1,
568564
};
569565

570-
let flow_three = Flow {
566+
let flow_three = ValidationFlow {
571567
flow_id: 3,
572568
r#type: "REST".to_string(),
573569
settings: get_settings(),
@@ -611,7 +607,7 @@ mod tests {
611607
redis_integration_test!(
612608
query_all_flows,
613609
(|_connection: FlowStore, mut service: FlowStoreService| async move {
614-
let flow_one = Flow {
610+
let flow_one = ValidationFlow {
615611
flow_id: 1,
616612
r#type: "REST".to_string(),
617613
settings: get_settings(),
@@ -622,7 +618,7 @@ mod tests {
622618
project_id: 1,
623619
};
624620

625-
let flow_two = Flow {
621+
let flow_two = ValidationFlow {
626622
flow_id: 2,
627623
r#type: "REST".to_string(),
628624
settings: get_settings(),
@@ -633,7 +629,7 @@ mod tests {
633629
project_id: 1,
634630
};
635631

636-
let flow_three = Flow {
632+
let flow_three = ValidationFlow {
637633
flow_id: 3,
638634
r#type: "REST".to_string(),
639635
settings: get_settings(),
@@ -667,7 +663,7 @@ mod tests {
667663
redis_integration_test!(
668664
query_one_existing_flow,
669665
(|_connection: FlowStore, mut service: FlowStoreService| async move {
670-
let flow_one = Flow {
666+
let flow_one = ValidationFlow {
671667
flow_id: 1,
672668
r#type: "REST".to_string(),
673669
settings: get_settings(),
@@ -678,7 +674,7 @@ mod tests {
678674
project_id: 1,
679675
};
680676

681-
let flow_two = Flow {
677+
let flow_two = ValidationFlow {
682678
flow_id: 2,
683679
r#type: "REST".to_string(),
684680
settings: get_settings(),
@@ -689,7 +685,7 @@ mod tests {
689685
project_id: 1,
690686
};
691687

692-
let flow_three = Flow {
688+
let flow_three = ValidationFlow {
693689
flow_id: 3,
694690
r#type: "REST".to_string(),
695691
settings: get_settings(),

0 commit comments

Comments
 (0)