From 07cfcd3185bf7b6dc6a14dbc551a0bf450ade49a Mon Sep 17 00:00:00 2001 From: Ihor M Date: Thu, 24 Jun 2021 11:17:14 +0200 Subject: [PATCH 1/3] timeouts --- Cargo.lock | 4 +++- Cargo.toml | 2 +- src/service_requester.rs | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 884b188..e97d570 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "actix" version = "0.10.0" @@ -1396,7 +1398,7 @@ dependencies = [ [[package]] name = "microtools" -version = "0.2.2" +version = "0.2.3" dependencies = [ "actix", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 0a5f802..e9203b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "microtools" -version = "0.2.2" +version = "0.2.3" authors = ["Bodo Junglas ", "Ihor Mordashev BusinessResult { + ServiceRequester::with_service_auth_with_timeout(service_name, scopes, 120) + } + + pub fn with_service_auth_with_timeout(service_name: &str, scopes: &[(&str, &[&str])], timeout_seconds: u16) -> BusinessResult { Ok(ServiceRequester { client: Client::builder() - .connect_timeout(Duration::from_secs(20)) - .timeout(Duration::from_secs(60)) + .connect_timeout(Duration::from_secs(timeout_seconds as u64)) + .timeout(Duration::from_secs(timeout_seconds as u64)) .redirect(Policy::none()) .build()?, token_creator: TokenCreator::for_service(service_name, scopes).start(), From 1f897cc03917b76f37715071d4a2b57f6b130849 Mon Sep 17 00:00:00 2001 From: Ihor M Date: Thu, 24 Jun 2021 11:18:06 +0200 Subject: [PATCH 2/3] version update --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8833012..d24aa71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "microtools" -version = "0.3.3" +version = "0.3.4" authors = ["Bodo Junglas ", "Ihor Mordashev Date: Thu, 24 Jun 2021 11:23:46 +0200 Subject: [PATCH 3/3] readme & format --- README.md | 4 ++++ src/service_requester.rs | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4a82e25..4d4d46f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # microtools-rs Minimal toolbox to write backend services in rust + +## Test & Check + +> cargo fmt -- --check && cargo clippy && cargo test \ No newline at end of file diff --git a/src/service_requester.rs b/src/service_requester.rs index c82ee91..d7eee42 100644 --- a/src/service_requester.rs +++ b/src/service_requester.rs @@ -35,12 +35,15 @@ pub struct ServiceRequester { } impl ServiceRequester { - pub fn with_service_auth(service_name: &str, scopes: &[(&str, &[&str])]) -> BusinessResult { ServiceRequester::with_service_auth_with_timeout(service_name, scopes, 120) } - pub fn with_service_auth_with_timeout(service_name: &str, scopes: &[(&str, &[&str])], timeout_seconds: u16) -> BusinessResult { + pub fn with_service_auth_with_timeout( + service_name: &str, + scopes: &[(&str, &[&str])], + timeout_seconds: u16, + ) -> BusinessResult { Ok(ServiceRequester { client: Client::builder() .connect_timeout(Duration::from_secs(timeout_seconds as u64))