Skip to content

Commit

Permalink
Merge pull request #4320 from systeminit/nick/bug-487
Browse files Browse the repository at this point in the history
Fix function timeout set to 0 by default
  • Loading branch information
nickgerace authored Aug 10, 2024
2 parents b717360 + 99968ba commit 022a474
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
19 changes: 7 additions & 12 deletions lib/veritech-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ pub struct Config {
#[builder(default = "healthcheck_pool_default()")]
healthcheck_pool: bool,

#[builder(default = "default_cyclone_client_execution_timeout()")]
cyclone_client_execution_timeout: u64,
#[builder(default)]
cyclone_client_execution_timeout: Option<u64>,
}

#[remain::sorted]
Expand All @@ -86,7 +86,7 @@ pub struct ConfigFile {
pub cyclone: CycloneConfig,
pub crypto: VeritechCryptoConfig,
pub healthcheck_pool: bool,
pub cyclone_client_execution_timeout: u64,
pub cyclone_client_execution_timeout: Option<u64>,
}

impl ConfigFile {
Expand All @@ -96,7 +96,7 @@ impl ConfigFile {
cyclone: CycloneConfig::default_local_http(),
crypto: Default::default(),
healthcheck_pool: healthcheck_pool_default(),
cyclone_client_execution_timeout: default_cyclone_client_execution_timeout(),
cyclone_client_execution_timeout: None,
}
}

Expand All @@ -106,14 +106,13 @@ impl ConfigFile {
cyclone: CycloneConfig::default_local_uds(),
crypto: Default::default(),
healthcheck_pool: healthcheck_pool_default(),
cyclone_client_execution_timeout: default_cyclone_client_execution_timeout(),
cyclone_client_execution_timeout: None,
}
}

pub fn new_for_dal_test(nats: NatsConfig) -> Self {
Self {
nats,
cyclone_client_execution_timeout: default_cyclone_client_execution_timeout(),
..Default::default()
}
}
Expand Down Expand Up @@ -175,8 +174,8 @@ impl Config {
self.cyclone_spec
}

/// Gets the config's execution timeout, in seconds.
pub fn cyclone_client_execution_timeout(&self) -> u64 {
/// Gets the config's option override cyclone client execution timeout, in seconds.
pub fn cyclone_client_execution_timeout(&self) -> Option<u64> {
self.cyclone_client_execution_timeout
}
}
Expand Down Expand Up @@ -511,10 +510,6 @@ fn healthcheck_pool_default() -> bool {
true
}

fn default_cyclone_client_execution_timeout() -> u64 {
35 * 60
}

#[allow(clippy::disallowed_methods)] // Used to determine if running in development
pub fn detect_and_configure_development(config: &mut ConfigFile) -> Result<()> {
if env::var("BUCK_RUN_BUILD_ID").is_ok() || env::var("BUCK_BUILD_ID").is_ok() {
Expand Down
11 changes: 8 additions & 3 deletions lib/veritech-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use crate::{
PublisherError,
};

const DEFAULT_CYCLONE_CLIENT_EXECUTION_TIMEOUT: Duration = Duration::from_secs(35 * 60);

#[remain::sorted]
#[derive(Error, Debug)]
pub enum ServerError {
Expand Down Expand Up @@ -164,9 +166,12 @@ impl Server {
shutdown_tx,
shutdown_rx: graceful_shutdown_rx,
metadata: Arc::new(metadata),
cyclone_client_execution_timeout: Duration::from_secs(
config.cyclone_client_execution_timeout(),
),
cyclone_client_execution_timeout: match config
.cyclone_client_execution_timeout()
{
Some(timeout) => Duration::from_secs(timeout),
None => DEFAULT_CYCLONE_CLIENT_EXECUTION_TIMEOUT,
},
})
}
wrong @ CycloneSpec::LocalHttp(_) => Err(ServerError::WrongCycloneSpec(
Expand Down

0 comments on commit 022a474

Please sign in to comment.