From 4b180f34d2dd3d3265fc5eccabf00e11325fe3a3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 26 Jun 2026 20:18:08 +0200 Subject: [PATCH] feat: made timeout configurable --- src/flow_service/mod.rs | 12 ++++++++++-- src/flow_service/retry.rs | 10 +++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/flow_service/mod.rs b/src/flow_service/mod.rs index d442e4d..0236880 100644 --- a/src/flow_service/mod.rs +++ b/src/flow_service/mod.rs @@ -2,6 +2,7 @@ use crate::{ flow_definition::Reader, flow_service::{auth::get_authorization_metadata, retry::create_channel_with_retry}, }; +use tokio::time::Duration; use tonic::{Extensions, Request, transport::Channel}; use tucana::{ aquila::{ModuleUpdateRequest, module_service_client::ModuleServiceClient}, @@ -28,7 +29,13 @@ impl FlowUpdateService { /// /// This reads the definition files from the given path as modules and initializes the /// service with those module definitions. - pub async fn from_url(aquila_url: String, definition_path: &str, aquila_token: String) -> Self { + pub async fn from_url( + aquila_url: String, + definition_path: &str, + aquila_token: String, + connect_timeout: Duration, + request_timeout: Duration, + ) -> Self { let reader = Reader::configure(definition_path.to_string(), true, vec![], None); let modules = match reader.read_modules() { Ok(modules) => modules, @@ -38,7 +45,8 @@ impl FlowUpdateService { } }; - let channel = create_channel_with_retry("Aquila", aquila_url).await; + let channel = + create_channel_with_retry("Aquila", aquila_url, connect_timeout, request_timeout).await; Self { modules, diff --git a/src/flow_service/retry.rs b/src/flow_service/retry.rs index c491563..d046938 100644 --- a/src/flow_service/retry.rs +++ b/src/flow_service/retry.rs @@ -5,7 +5,12 @@ const MAX_BACKOFF: u64 = 2000 * 60; const MAX_RETRIES: i8 = 10; // Will create a channel and retry if its not possible -pub async fn create_channel_with_retry(channel_name: &str, url: String) -> Channel { +pub async fn create_channel_with_retry( + channel_name: &str, + url: String, + connect_timeout: Duration, + request_timeout: Duration, +) -> Channel { let mut backoff = 100; let mut retries = 0; @@ -13,8 +18,7 @@ pub async fn create_channel_with_retry(channel_name: &str, url: String) -> Chann let channel = match Endpoint::from_shared(url.clone()) { Ok(c) => { log::debug!("Creating a new endpoint for the: {} Service", channel_name); - c.connect_timeout(Duration::from_secs(2)) - .timeout(Duration::from_secs(10)) + c.connect_timeout(connect_timeout).timeout(request_timeout) } Err(err) => { panic!(