diff --git a/backend/basic/src/rbum/helper/rbum_event_helper.rs b/backend/basic/src/rbum/helper/rbum_event_helper.rs index 51fb8406b..c69869f0b 100644 --- a/backend/basic/src/rbum/helper/rbum_event_helper.rs +++ b/backend/basic/src/rbum/helper/rbum_event_helper.rs @@ -81,8 +81,8 @@ pub async fn get_notify_event_with_ctx(ctx: &TardisContext) -> TardisResult(v).unwrap()) - .collect::>(); + .map(|(_, v)| TardisFuns::json.str_to_obj::(v)) + .collect::>>()?; if notify_events.is_empty() { Ok(None) } else { diff --git a/backend/basic/src/rbum/serv/rbum_cert_serv.rs b/backend/basic/src/rbum/serv/rbum_cert_serv.rs index 0860cf65e..6980f2095 100644 --- a/backend/basic/src/rbum/serv/rbum_cert_serv.rs +++ b/backend/basic/src/rbum/serv/rbum_cert_serv.rs @@ -658,7 +658,7 @@ impl RbumCrudOperation>().len() as u64)) @@ -377,6 +377,7 @@ impl RbumSetServ { .filter(|cate| cate.pid == Some(cate_id.to_string())) .flat_map(|cate| Self::filter_exist_items(tree_main, &cate.id, rbum_set_items)) .collect::>(); + // TODO remove unwrap let cate = tree_main.iter().find(|cate| cate.id == cate_id).unwrap(); if sub_cates.is_empty() { // leaf node diff --git a/backend/basic/src/spi/spi_funs.rs b/backend/basic/src/spi/spi_funs.rs index 99293b4eb..ae6df8f63 100644 --- a/backend/basic/src/spi/spi_funs.rs +++ b/backend/basic/src/spi/spi_funs.rs @@ -33,12 +33,12 @@ impl SpiBsInst { where T: 'static, { - let c = self.client.as_ref().downcast_ref::().unwrap(); + let c = self.client.as_ref().downcast_ref::().expect("ignore"); (c, &self.ext, self.kind_code()) } pub fn kind_code(&self) -> &str { - self.ext.get(spi_constants::SPI_KIND_CODE_FLAG).unwrap() + self.ext.get(spi_constants::SPI_KIND_CODE_FLAG).expect("ignore") } } diff --git a/backend/basic/src/spi/spi_initializer.rs b/backend/basic/src/spi/spi_initializer.rs index 16e6f1ca8..3c8b4470c 100644 --- a/backend/basic/src/spi/spi_initializer.rs +++ b/backend/basic/src/spi/spi_initializer.rs @@ -240,8 +240,8 @@ pub mod common_pg { let compatible_type = TardisFuns::json.json_to_obj(ext.get("compatible_type").unwrap_or(&tardis::serde_json::Value::String("None".to_string())).clone())?; let client = TardisRelDBClient::init(&DBModuleConfig { url: bs_cert.conn_uri.parse().expect("invalid url"), - max_connections: ext.get("max_connections").unwrap().as_u64().unwrap() as u32, - min_connections: ext.get("min_connections").unwrap().as_u64().unwrap() as u32, + max_connections: ext.get("max_connections").map(|c| c.as_u64()).flatten().unwrap_or(5) as u32, + min_connections: ext.get("min_connections").map(|c| c.as_u64()).flatten().unwrap_or(1) as u32, connect_timeout_sec: None, idle_timeout_sec: None, compatible_type, @@ -289,7 +289,7 @@ pub mod common_pg { ) -> TardisResult<(TardisRelDBlConnection, String)> { let tag = tag.map(|t| format!("_{t}")).unwrap_or_default(); let conn = bs_inst.0.conn(); - let schema_name = get_schema_name_from_ext(bs_inst.1).unwrap(); + let schema_name = get_schema_name_from_ext(bs_inst.1).expect("ignore"); if check_table_exit(&format!("{table_flag}{tag}"), &conn, ctx).await? { return Ok((conn, format!("{schema_name}.{GLOBAL_STORAGE_FLAG}_{table_flag}{tag}"))); } else if !mgr { @@ -303,7 +303,7 @@ pub mod common_pg { /// 初始化连接 pub async fn init_conn(bs_inst: TypedSpiBsInst<'_, TardisRelDBClient>) -> TardisResult<(TardisRelDBlConnection, String)> { let conn = bs_inst.0.conn(); - let schema_name = get_schema_name_from_ext(bs_inst.1).unwrap(); + let schema_name = get_schema_name_from_ext(bs_inst.1).expect("ignore"); Ok((conn, schema_name)) } diff --git a/backend/gateways/test/src/init_apisix.rs b/backend/gateways/test/src/init_apisix.rs deleted file mode 100644 index 824e29d10..000000000 --- a/backend/gateways/test/src/init_apisix.rs +++ /dev/null @@ -1,51 +0,0 @@ -use tardis::basic::result::TardisResult; -use tardis::serde_json::json; -use tardis::testcontainers::clients::Cli; -use tardis::testcontainers::core::WaitFor; -use tardis::testcontainers::{Container, GenericImage, RunnableImage}; -use tardis::TardisFuns; - -pub(crate) async fn init(docker: &Cli) -> TardisResult<(String, Container)> { - // Build docker image - let (_code, output, _error) = run_script::run_script!( - r#" - docker rm -f apisix_test - docker build -f gateways/test/conf/apisix/Dockerfile_with_etcd -t apisix_test gateways/ - "# - ) - .unwrap(); - // println!("Exit Code: {}", code); - // println!("Error: {}", error); - println!("Output: {}", output); - - // Start docker container - let image = GenericImage::new("apisix_test", "latest").with_wait_for(WaitFor::seconds(15)); - let mut runnable_image: RunnableImage = image.into(); - runnable_image = runnable_image.with_network("host"); - runnable_image = runnable_image.with_container_name("apisix_test"); - let node = docker.run(runnable_image); - let url = "http://127.0.0.1:9080"; - // Init routes - TardisFuns::web_client() - .put_obj_to_str( - &format!("{url}/apisix/admin/routes/1"), - &json!({ - "uri": "/*", - "plugins": { - "auth-bios": { - "host": "http://127.0.0.1:8080/auth", - "timeout": 60000 - } - }, - "upstream": { - "type": "roundrobin", - "nodes": { - "127.0.0.1:8080": 1 - } - } - }), - vec![("X-API-KEY".to_string(), "edd1c9f034335f136f87ad84b6acecs1".to_string())], - ) - .await?; - Ok((url.to_string(), node)) -}