From 9e17c517fe91b018753d9d3001821146bd433ef8 Mon Sep 17 00:00:00 2001 From: Integral Date: Mon, 9 Dec 2024 17:31:07 +0800 Subject: [PATCH] refactor: replace static with const for global constants (#5250) --- crates/api_common/src/utils.rs | 2 +- crates/federate/src/worker.rs | 4 ++-- crates/utils/src/settings/mod.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index 2a5981b70..21154c823 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -76,7 +76,7 @@ use tracing::warn; use url::{ParseError, Url}; use urlencoding::encode; -pub static AUTH_COOKIE_NAME: &str = "jwt"; +pub const AUTH_COOKIE_NAME: &str = "jwt"; #[tracing::instrument(skip_all)] pub async fn is_mod_or_admin( diff --git a/crates/federate/src/worker.rs b/crates/federate/src/worker.rs index 047c5a5d6..1d666cfa3 100644 --- a/crates/federate/src/worker.rs +++ b/crates/federate/src/worker.rs @@ -44,9 +44,9 @@ const MAX_SUCCESSFULS: usize = 1000; /// in prod mode, try to collect multiple send results at the same time to reduce load #[cfg(not(test))] -static MIN_ACTIVITY_SEND_RESULTS_TO_HANDLE: usize = 4; +const MIN_ACTIVITY_SEND_RESULTS_TO_HANDLE: usize = 4; #[cfg(test)] -static MIN_ACTIVITY_SEND_RESULTS_TO_HANDLE: usize = 0; +const MIN_ACTIVITY_SEND_RESULTS_TO_HANDLE: usize = 0; /// /// SendManager --(has many)--> InstanceWorker --(has many)--> SendRetryTask diff --git a/crates/utils/src/settings/mod.rs b/crates/utils/src/settings/mod.rs index 986c19059..d6f11c09b 100644 --- a/crates/utils/src/settings/mod.rs +++ b/crates/utils/src/settings/mod.rs @@ -10,7 +10,7 @@ pub mod structs; use structs::{DatabaseConnection, PictrsConfig, PictrsImageMode, Settings}; -static DEFAULT_CONFIG_FILE: &str = "config/config.hjson"; +const DEFAULT_CONFIG_FILE: &str = "config/config.hjson"; #[allow(clippy::expect_used)] pub static SETTINGS: LazyLock = LazyLock::new(|| {