Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

build(deps): migrate usages of `once_cell` crate to standard library equivalents (#8030)

Sanchith Hegde673cf249b03b
diff --git a/Cargo.lock b/Cargo.lock
index 6df00ec751..2f69054921 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -360,7 +360,6 @@ dependencies = [
"hyperswitch_domain_models",
"hyperswitch_interfaces",
"masking",
- "once_cell",
"opensearch",
"reqwest 0.11.27",
"router_env",
@@ -1558,7 +1557,6 @@ dependencies = [
"common_utils",
"error-stack",
"masking",
- "once_cell",
"regex",
"router_env",
"serde",
@@ -2622,7 +2620,6 @@ dependencies = [
"hyperswitch_interfaces",
"masking",
"mime",
- "once_cell",
"redis_interface",
"reqwest 0.11.27",
"router_env",
@@ -2845,7 +2842,6 @@ dependencies = [
"euclid_macros",
"hyperswitch_constraint_graph",
"nom",
- "once_cell",
"rustc-hash",
"serde",
"serde_json",
@@ -2878,7 +2874,6 @@ dependencies = [
"getrandom",
"hyperswitch_constraint_graph",
"kgraph_utils",
- "once_cell",
"ron-parser",
"serde",
"serde-wasm-bindgen 0.6.5",
@@ -3866,7 +3861,6 @@ dependencies = [
"masking",
"mime",
"num-traits",
- "once_cell",
"qrcode",
"quick-xml",
"rand",
@@ -3949,7 +3943,6 @@ dependencies = [
"hyperswitch_domain_models",
"masking",
"mime",
- "once_cell",
"reqwest 0.11.27",
"router_derive",
"router_env",
@@ -6604,7 +6597,6 @@ dependencies = [
"config",
"error-stack",
"gethostname",
- "once_cell",
"opentelemetry",
"opentelemetry-aws",
"opentelemetry-otlp",
@@ -6991,7 +6983,6 @@ dependencies = [
"futures 0.3.30",
"hyperswitch_domain_models",
"num_cpus",
- "once_cell",
"rand",
"redis_interface",
"router_env",
@@ -7820,7 +7811,6 @@ dependencies = [
"hyperswitch_domain_models",
"masking",
"moka",
- "once_cell",
"redis_interface",
"router_derive",
"router_env",
diff --git a/crates/analytics/Cargo.toml b/crates/analytics/Cargo.toml
index ab63e47d8f..6f94b70a6d 100644
--- a/crates/analytics/Cargo.toml
+++ b/crates/analytics/Cargo.toml
@@ -32,7 +32,6 @@ aws-smithy-types = { version = "1.3.0" }
bigdecimal = { version = "0.4.5", features = ["serde"] }
error-stack = "0.4.1"
futures = "0.3.30"
-once_cell = "1.19.0"
opensearch = { version = "2.2.0", features = ["aws-auth"] }
reqwest = { version = "0.11.27", features = ["serde_json"] }
rust_decimal = "1.35"
diff --git a/crates/analytics/src/metrics/request.rs b/crates/analytics/src/metrics/request.rs
index 7b84347b73..1b003b87ae 100644
--- a/crates/analytics/src/metrics/request.rs
+++ b/crates/analytics/src/metrics/request.rs
@@ -1,7 +1,7 @@
#[inline]
pub async fn record_operation_time<F, R, T>(
future: F,
- metric: &once_cell::sync::Lazy<router_env::opentelemetry::metrics::Histogram<f64>>,
+ metric: &router_env::opentelemetry::metrics::Histogram<f64>,
metric_name: &T,
source: &crate::AnalyticsProvider,
) -> R
diff --git a/crates/cards/Cargo.toml b/crates/cards/Cargo.toml
index 1d194e8690..b6b9f2b886 100644
--- a/crates/cards/Cargo.toml
+++ b/crates/cards/Cargo.toml
@@ -11,7 +11,6 @@ license.workspace = true
[dependencies]
error-stack = "0.4.1"
-once_cell = "1.19.0"
serde = { version = "1.0.197", features = ["derive"] }
thiserror = "1.0.58"
time = "0.3.35"
diff --git a/crates/cards/src/validate.rs b/crates/cards/src/validate.rs
index b8b9cdbf18..998097c855 100644
--- a/crates/cards/src/validate.rs
+++ b/crates/cards/src/validate.rs
@@ -1,9 +1,8 @@
-use std::{collections::HashMap, fmt, ops::Deref, str::FromStr};
+use std::{collections::HashMap, fmt, ops::Deref, str::FromStr, sync::LazyLock};
use common_utils::errors::ValidationError;
use error_stack::report;
use masking::{PeekInterface, Strategy, StrongSecret, WithType};
-use once_cell::sync::Lazy;
use regex::Regex;
#[cfg(not(target_arch = "wasm32"))]
use router_env::{logger, which as router_env_which, Env};
@@ -52,8 +51,8 @@ impl CardNumber {
}
pub fn is_cobadged_card(&self) -> Result<bool, error_stack::Report<ValidationError>> {
/// Regex to identify card networks
- static CARD_NETWORK_REGEX: Lazy<HashMap<&str, Result<Regex, regex::Error>>> = Lazy::new(
- || {
+ static CARD_NETWORK_REGEX: LazyLock<HashMap<&str, Result<Regex, regex::Error>>> =
+ LazyLock::new(|| {
let mut map = HashMap::new();
map.insert(
"Mastercard",
@@ -82,8 +81,7 @@ impl CardNumber {
map.insert("BAJAJ", Regex::new(r"^(203040)"));
map.insert("CartesBancaires", Regex::new(r"^(401(005|006|581)|4021(01|02)|403550|405936|406572|41(3849|4819|50(56|59|62|71|74)|6286|65(37|79)|71[7])|420110|423460|43(47(21|22)|50(48|49|50|51|52)|7875|95(09|11|15|39|98)|96(03|18|19|20|22|72))|4424(48|49|50|51|52|57)|448412|4505(19|60)|45(33|56[6-8]|61|62[^3]|6955|7452|7717|93[02379])|46(099|54(76|77)|6258|6575|98[023])|47(4107|71(73|74|86)|72(65|93)|9619)|48(1091|3622|6519)|49(7|83[5-9]|90(0[1-6]|1[0-6]|2[0-3]|3[0-3]|4[0-3]|5[0-2]|68|9[256789]))|5075(89|90|93|94|97)|51(0726|3([0-7]|8[56]|9(00|38))|5214|62(07|36)|72(22|43)|73(65|66)|7502|7647|8101|9920)|52(0993|1662|3718|7429|9227|93(13|14|31)|94(14|21|30|40|47|55|56|[6-9])|9542)|53(0901|10(28|30)|1195|23(4[4-7])|2459|25(09|34|54|56)|3801|41(02|05|11)|50(29|66)|5324|61(07|15)|71(06|12)|8011)|54(2848|5157|9538|98(5[89]))|55(39(79|93)|42(05|60)|4965|7008|88(67|82)|89(29|4[23])|9618|98(09|10))|56(0408|12(0[2-6]|4[134]|5[04678]))|58(17(0[0-7]|15|2[14]|3[16789]|4[0-9]|5[016]|6[269]|7[3789]|8[0-7]|9[017])|55(0[2-5]|7[7-9]|8[0-2])))"));
map
- },
- );
+ });
let mut no_of_supported_card_networks = 0;
let card_number_str = self.get_card_no();
diff --git a/crates/common_utils/src/validation.rs b/crates/common_utils/src/validation.rs
index 007674a0db..0edb927233 100644
--- a/crates/common_utils/src/validation.rs
+++ b/crates/common_utils/src/validation.rs
@@ -1,10 +1,9 @@
//! Custom validations for some shared types.
-use std::collections::HashSet;
+use std::{collections::HashSet, sync::LazyLock};
use error_stack::report;
use globset::Glob;
-use once_cell::sync::Lazy;
use regex::Regex;
#[cfg(feature = "logs")]
use router_env::logger;
@@ -25,7 +24,7 @@ pub fn validate_phone_number(phone_number: &str) -> Result<(), ValidationError>
/// Performs a simple validation against a provided email address.
pub fn validate_email(email: &str) -> CustomResult<(), ValidationError> {
#[deny(clippy::invalid_regex)]
- static EMAIL_REGEX: Lazy<Option<Regex>> = Lazy::new(|| {
+ static EMAIL_REGEX: LazyLock<Option<Regex>> = LazyLock::new(|| {
#[allow(unknown_lints)]
#[allow(clippy::manual_ok_err)]
match Regex::new(
diff --git a/crates/diesel_models/src/lib.rs b/crates/diesel_models/src/lib.rs
index d9163b02aa..e5c7aea9d5 100644
--- a/crates/diesel_models/src/lib.rs
+++ b/crates/diesel_models/src/lib.rs
@@ -133,7 +133,7 @@ pub(crate) mod diesel_impl {
}
pub(crate) mod metrics {
- use router_env::{counter_metric, global_meter, histogram_metric_f64, once_cell};
+ use router_env::{counter_metric, global_meter, histogram_metric_f64};
global_meter!(GLOBAL_METER, "ROUTER_API");
diff --git a/crates/drainer/Cargo.toml b/crates/drainer/Cargo.toml
index a783e8c912..f6cfc7760f 100644
--- a/crates/drainer/Cargo.toml
+++ b/crates/drainer/Cargo.toml
@@ -22,7 +22,6 @@ config = { version = "0.14.0", features = ["toml"] }
diesel = { version = "2.2.3", features = ["postgres"] }
error-stack = "0.4.1"
mime = "0.3.17"
-once_cell = "1.19.0"
reqwest = { version = "0.11.27" }
serde = "1.0.197"
serde_json = "1.0.115"
diff --git a/crates/euclid/Cargo.toml b/crates/euclid/Cargo.toml
index a607531d87..cba20fed35 100644
--- a/crates/euclid/Cargo.toml
+++ b/crates/euclid/Cargo.toml
@@ -8,7 +8,6 @@ license.workspace = true
[dependencies]
nom = { version = "7.1.3", features = ["alloc"], optional = true }
-once_cell = "1.19.0"
rustc-hash = "1.1.0"
serde = { version = "1.0.197", features = ["derive", "rc"] }
serde_json = "1.0.115"
diff --git a/crates/euclid/src/dssa/analyzer.rs b/crates/euclid/src/dssa/analyzer.rs
index 7aeb850e1b..fb5cfc957c 100644
--- a/crates/euclid/src/dssa/analyzer.rs
+++ b/crates/euclid/src/dssa/analyzer.rs
@@ -315,6 +315,8 @@ mod tests {
& payment_method /= gift_card
& payment_method /= card_redirect
& payment_method /= real_time_payment
+ & payment_method /= open_banking
+ & payment_method /= mobile_payment
}
}
}
diff --git a/crates/euclid/src/dssa/truth.rs b/crates/euclid/src/dssa/truth.rs
index 949d9e2f11..8724979888 100644
--- a/crates/euclid/src/dssa/truth.rs
+++ b/crates/euclid/src/dssa/truth.rs
@@ -1,10 +1,11 @@
+use std::sync::LazyLock;
+
use euclid_macros::knowledge;
-use once_cell::sync::Lazy;
use crate::{dssa::graph::euclid_graph_prelude, frontend::dir};
-pub static ANALYSIS_GRAPH: Lazy<hyperswitch_constraint_graph::ConstraintGraph<dir::DirValue>> =
- Lazy::new(|| {
+pub static ANALYSIS_GRAPH: LazyLock<hyperswitch_constraint_graph::ConstraintGraph<dir::DirValue>> =
+ LazyLock::new(|| {
knowledge! {
// Payment Method should be `Card` for a CardType to be present
PaymentMethod(Card) ->> CardType(any);
diff --git a/crates/euclid_wasm/Cargo.toml b/crates/euclid_wasm/Cargo.toml
index 9c22ed6231..42480b5ed4 100644
--- a/crates/euclid_wasm/Cargo.toml
+++ b/crates/euclid_wasm/Cargo.toml
@@ -31,7 +31,6 @@ kgraph_utils = { version = "0.1.0", path = "../kgraph_utils" }
# Third party crates
getrandom = { version = "0.2.12", features = ["js"] }
-once_cell = "1.19.0"
ron-parser = "0.1.4"
serde = { version = "1.0", features = [] }
serde-wasm-bindgen = "0.6.5"
diff --git a/crates/euclid_wasm/src/lib.rs b/crates/euclid_wasm/src/lib.rs
index c08312b7b8..d6eb644c6c 100644
--- a/crates/euclid_wasm/src/lib.rs
+++ b/crates/euclid_wasm/src/lib.rs
@@ -4,6 +4,7 @@ mod utils;
use std::{
collections::{HashMap, HashSet},
str::FromStr,
+ sync::OnceLock,
};
use api_models::{
@@ -27,7 +28,6 @@ use euclid::{
dir::{self, enums as dir_enums, EuclidDirFilter},
},
};
-use once_cell::sync::OnceCell;
use strum::{EnumMessage, EnumProperty, VariantNames};
use wasm_bindgen::prelude::*;
@@ -42,8 +42,8 @@ struct SeedData {
connectors: Vec<ast::ConnectorChoice>,
}
-static SEED_DATA: OnceCell<SeedData> = OnceCell::new();
-static SEED_FOREX: OnceCell<currency_conversion_types::ExchangeRates> = OnceCell::new();
+static SEED_DATA: OnceLock<SeedData> = OnceLock::new();
+static SEED_FOREX: OnceLock<currency_conversion_types::ExchangeRates> = OnceLock::new();
/// This function can be used by the frontend to educate wasm about the forex rates data.
/// The input argument is a struct fields base_currency and conversion where later is all the conversions associated with the base_currency
diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml
index 38647cc14a..08a807c6f4 100644
--- a/crates/hyperswitch_connectors/Cargo.toml
+++ b/crates/hyperswitch_connectors/Cargo.toml
@@ -9,8 +9,8 @@ license.workspace = true
frm = ["hyperswitch_domain_models/frm", "hyperswitch_interfaces/frm"]
payouts = ["hyperswitch_domain_models/payouts", "api_models/payouts", "hyperswitch_interfaces/payouts"]
v1 = ["api_models/v1", "hyperswitch_domain_models/v1", "common_utils/v1"]
-v2 = ["api_models/v2", "hyperswitch_domain_models/v2", "common_utils/v2","hyperswitch_interfaces/v2"]
-revenue_recovery = ["hyperswitch_interfaces/revenue_recovery","hyperswitch_domain_models/revenue_recovery"]
+v2 = ["api_models/v2", "hyperswitch_domain_models/v2", "common_utils/v2", "hyperswitch_interfaces/v2"]
+revenue_recovery = ["hyperswitch_interfaces/revenue_recovery", "hyperswitch_domain_models/revenue_recovery"]
[dependencies]
actix-http = "3.6.0"
@@ -25,10 +25,9 @@ http = "0.2.12"
iso_currency = "0.4.4"
isocountry = "0.3.2"
image = { version = "0.25.1", default-features = false, features = ["png"] }
-josekit = { git = "https://github.com/sumanmaji4/josekit-rs.git", rev = "5ab54876c29a84f86aef8c169413a46026883efe", features = ["support-empty-payload"]}
+josekit = { git = "https://github.com/sumanmaji4/josekit-rs.git", rev = "5ab54876c29a84f86aef8c169413a46026883efe", features = ["support-empty-payload"] }
mime = "0.3.17"
num-traits = "0.2.19"
-once_cell = "1.19.0"
qrcode = "0.14.0"
quick-xml = { version = "0.31.0", features = ["serialize"] }
rand = "0.8.5"
@@ -58,7 +57,7 @@ api_models = { version = "0.1.0", path = "../api_models", features = ["errors"],
cards = { version = "0.1.0", path = "../cards" }
common_enums = { version = "0.1.0", path = "../common_enums" }
common_types = { version = "0.1.0", path = "../common_types" }
-common_utils = { version = "0.1.0", path = "../common_utils", features = ["async_ext","logs","metrics","crypto_openssl"] }
+common_utils = { version = "0.1.0", path = "../common_utils", features = ["async_ext", "logs", "metrics", "crypto_openssl"] }
hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces", default-features = false }
masking = { version = "0.1.0", path = "../masking" }
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index c3c3a23baa..90b97471be 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -2,6 +2,7 @@ use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
+ sync::LazyLock,
};
use api_models::payments;
@@ -66,7 +67,6 @@ use hyperswitch_domain_models::{
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use image::{DynamicImage, ImageBuffer, ImageFormat, Luma, Rgba};
use masking::{ExposeInterface, PeekInterface, Secret};
-use once_cell::sync::Lazy;
use rand::Rng;
use regex::Regex;
use router_env::logger;
@@ -1297,29 +1297,31 @@ fn get_card_issuer(card_number: &str) -> Result<CardIssuer, Error> {
))
}
-static CARD_REGEX: Lazy<HashMap<CardIssuer, Result<Regex, regex::Error>>> = Lazy::new(|| {
- let mut map = HashMap::new();
- // Reference: https://gist.github.com/michaelkeevildown/9096cd3aac9029c4e6e05588448a8841
- // [#379]: Determine card issuer from card BIN number
- map.insert(CardIssuer::Master, Regex::new(r"^5[1-5][0-9]{14}$"));
- map.insert(CardIssuer::AmericanExpress, Regex::new(r"^3[47][0-9]{13}$"));
- map.insert(CardIssuer::Visa, Regex::new(r"^4[0-9]{12}(?:[0-9]{3})?$"));
- map.insert(CardIssuer::Discover, Regex::new(r"^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$"));
- map.insert(
- CardIssuer::Maestro,
- Regex::new(r"^(5018|5020|5038|5893|6304|6759|6761|6762|6763)[0-9]{8,15}$"),
- );
- map.insert(
- CardIssuer::DinersClub,
- Regex::new(r"^3(?:0[0-5]|[68][0-9])[0-9]{11}$"),
- );
- map.insert(
- CardIssuer::JCB,
- Regex::new(r"^(3(?:088|096|112|158|337|5(?:2[89]|[3-8][0-9]))\d{12})$"),
- );
- map.insert(CardIssuer::CarteBlanche, Regex::new(r"^389[0-9]{11}$"));
- map
-});
+static CARD_REGEX: LazyLock<HashMap<CardIssuer, Result<Regex, regex::Error>>> = LazyLock::new(
+ || {
+ let mut map = HashMap::new();
+ // Reference: https://gist.github.com/michaelkeevildown/9096cd3aac9029c4e6e05588448a8841
+ // [#379]: Determine card issuer from card BIN number
+ map.insert(CardIssuer::Master, Regex::new(r"^5[1-5][0-9]{14}$"));
+ map.insert(CardIssuer::AmericanExpress, Regex::new(r"^3[47][0-9]{13}$"));
+ map.insert(CardIssuer::Visa, Regex::new(r"^4[0-9]{12}(?:[0-9]{3})?$"));
+ map.insert(CardIssuer::Discover, Regex::new(r"^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$"));
+ map.insert(
+ CardIssuer::Maestro,
+ Regex::new(r"^(5018|5020|5038|5893|6304|6759|6761|6762|6763)[0-9]{8,15}$"),
+ );
+ map.insert(
+ CardIssuer::DinersClub,
+ Regex::new(r"^3(?:0[0-5]|[68][0-9])[0-9]{11}$"),
+ );
+ map.insert(
+ CardIssuer::JCB,
+ Regex::new(r"^(3(?:088|096|112|158|337|5(?:2[89]|[3-8][0-9]))\d{12})$"),
+ );
+ map.insert(CardIssuer::CarteBlanche, Regex::new(r"^389[0-9]{11}$"));
+ map
+ },
+);
pub trait AddressDetailsData {
fn get_first_name(&self) -> Result<&Secret<String>, Error>;
@@ -6146,8 +6148,8 @@ pub fn generate_12_digit_number() -> u64 {
pub fn normalize_string(value: String) -> Result<String, regex::Error> {
let nfkd_value = value.nfkd().collect::<String>();
let lowercase_value = nfkd_value.to_lowercase();
- static REGEX: std::sync::LazyLock<Result<Regex, regex::Error>> =
- std::sync::LazyLock::new(|| Regex::new(r"[^a-z0-9]"));
+ static REGEX: LazyLock<Result<Regex, regex::Error>> =
+ LazyLock::new(|| Regex::new(r"[^a-z0-9]"));
let regex = REGEX.as_ref().map_err(|e| e.clone())?;
let normalized = regex.replace_all(&lowercase_value, "").to_string();
Ok(normalized)
diff --git a/crates/hyperswitch_domain_models/src/consts.rs b/crates/hyperswitch_domain_models/src/consts.rs
index 93fd63deb6..49df11976f 100644
--- a/crates/hyperswitch_domain_models/src/consts.rs
+++ b/crates/hyperswitch_domain_models/src/consts.rs
@@ -1,11 +1,9 @@
//! Constants that are used in the domain models.
-use std::collections::HashSet;
+use std::{collections::HashSet, sync::LazyLock};
-use router_env::once_cell::sync::Lazy;
-
-pub static ROUTING_ENABLED_PAYMENT_METHODS: Lazy<HashSet<common_enums::PaymentMethod>> =
- Lazy::new(|| {
+pub static ROUTING_ENABLED_PAYMENT_METHODS: LazyLock<HashSet<common_enums::PaymentMethod>> =
+ LazyLock::new(|| {
let mut set = HashSet::new();
set.insert(common_enums::PaymentMethod::BankTransfer);
set.insert(common_enums::PaymentMethod::BankDebit);
@@ -13,16 +11,17 @@ pub static ROUTING_ENABLED_PAYMENT_METHODS: Lazy<HashSet<common_enums::PaymentMe
set
});
-pub static ROUTING_ENABLED_PAYMENT_METHOD_TYPES: Lazy<HashSet<common_enums::PaymentMethodType>> =
- Lazy::new(|| {
- let mut set = HashSet::new();
- set.insert(common_enums::PaymentMethodType::GooglePay);
- set.insert(common_enums::PaymentMethodType::ApplePay);
- set.insert(common_enums::PaymentMethodType::Klarna);
- set.insert(common_enums::PaymentMethodType::Paypal);
- set.insert(common_enums::PaymentMethodType::SamsungPay);
- set
- });
+pub static ROUTING_ENABLED_PAYMENT_METHOD_TYPES: LazyLock<
+ HashSet<common_enums::PaymentMethodType>,
+> = LazyLock::new(|| {
+ let mut set = HashSet::new();
+ set.insert(common_enums::PaymentMethodType::GooglePay);
+ set.insert(common_enums::PaymentMethodType::ApplePay);
+ set.insert(common_enums::PaymentMethodType::Klarna);
+ set.insert(common_enums::PaymentMethodType::Paypal);
+ set.insert(common_enums::PaymentMethodType::SamsungPay);
+ set
+});
/// Length of the unique reference ID generated for connector mandate requests
pub const CONNECTOR_MANDATE_REQUEST_REFERENCE_ID_LENGTH: usize = 18;
diff --git a/crates/hyperswitch_domain_models/src/type_encryption.rs b/crates/hyperswitch_domain_models/src/type_encryption.rs
index 07ff1caf7a..7562980615 100644
--- a/crates/hyperswitch_domain_models/src/type_encryption.rs
+++ b/crates/hyperswitch_domain_models/src/type_encryption.rs
@@ -1316,7 +1316,7 @@ where
}
pub(crate) mod metrics {
- use router_env::{counter_metric, global_meter, histogram_metric_f64, once_cell};
+ use router_env::{counter_metric, global_meter, histogram_metric_f64};
global_meter!(GLOBAL_METER, "ROUTER_API");
diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml
index f0402c45f7..5bbf29cdca 100644
--- a/crates/hyperswitch_interfaces/Cargo.toml
+++ b/crates/hyperswitch_interfaces/Cargo.toml
@@ -23,7 +23,6 @@ dyn-clone = "1.0.17"
error-stack = "0.4.1"
http = "0.2.12"
mime = "0.3.17"
-once_cell = "1.19.0"
reqwest = "0.11.27"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 9a64dfdaa6..7a0912e47d 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -1,6 +1,7 @@
use std::{
collections::{HashMap, HashSet},
str::FromStr,
+ sync::LazyLock,
};
#[cfg(feature = "payouts")]
@@ -24,7 +25,6 @@ use hyperswitch_domain_models::{
network_tokenization::NetworkTokenNumber, payments::payment_attempt::PaymentAttempt,
};
use masking::{Deserialize, ExposeInterface, Secret};
-use once_cell::sync::Lazy;
use regex::Regex;
#[cfg(feature = "frm")]
@@ -1346,29 +1346,31 @@ impl From<domain::GooglePayWalletData> for GooglePayWalletData {
}
}
-static CARD_REGEX: Lazy<HashMap<CardIssuer, Result<Regex, regex::Error>>> = Lazy::new(|| {
- let mut map = HashMap::new();
- // Reference: https://gist.github.com/michaelkeevildown/9096cd3aac9029c4e6e05588448a8841
- // [#379]: Determine card issuer from card BIN number
- map.insert(CardIssuer::Master, Regex::new(r"^5[1-5][0-9]{14}$"));
- map.insert(CardIssuer::AmericanExpress, Regex::new(r"^3[47][0-9]{13}$"));
- map.insert(CardIssuer::Visa, Regex::new(r"^4[0-9]{12}(?:[0-9]{3})?$"));
- map.insert(CardIssuer::Discover, Regex::new(r"^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$"));
- map.insert(
- CardIssuer::Maestro,
- Regex::new(r"^(5018|5020|5038|5893|6304|6759|6761|6762|6763)[0-9]{8,15}$"),
- );
- map.insert(
- CardIssuer::DinersClub,
- Regex::new(r"^3(?:0[0-5]|[68][0-9])[0-9]{11}$"),
- );
- map.insert(
- CardIssuer::JCB,
- Regex::new(r"^(3(?:088|096|112|158|337|5(?:2[89]|[3-8][0-9]))\d{12})$"),
- );
- map.insert(CardIssuer::CarteBlanche, Regex::new(r"^389[0-9]{11}$"));
- map
-});
+static CARD_REGEX: LazyLock<HashMap<CardIssuer, Result<Regex, regex::Error>>> = LazyLock::new(
+ || {
+ let mut map = HashMap::new();
+ // Reference: https://gist.github.com/michaelkeevildown/9096cd3aac9029c4e6e05588448a8841
+ // [#379]: Determine card issuer from card BIN number
+ map.insert(CardIssuer::Master, Regex::new(r"^5[1-5][0-9]{14}$"));
+ map.insert(CardIssuer::AmericanExpress, Regex::new(r"^3[47][0-9]{13}$"));
+ map.insert(CardIssuer::Visa, Regex::new(r"^4[0-9]{12}(?:[0-9]{3})?$"));
+ map.insert(CardIssuer::Discover, Regex::new(r"^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$"));
+ map.insert(
+ CardIssuer::Maestro,
+ Regex::new(r"^(5018|5020|5038|5893|6304|6759|6761|6762|6763)[0-9]{8,15}$"),
+ );
+ map.insert(
+ CardIssuer::DinersClub,
+ Regex::new(r"^3(?:0[0-5]|[68][0-9])[0-9]{11}$"),
+ );
+ map.insert(
+ CardIssuer::JCB,
+ Regex::new(r"^(3(?:088|096|112|158|337|5(?:2[89]|[3-8][0-9]))\d{12})$"),
+ );
+ map.insert(CardIssuer::CarteBlanche, Regex::new(r"^389[0-9]{11}$"));
+ map
+ },
+);
#[derive(Debug, Copy, Clone, strum::Display, Eq, Hash, PartialEq)]
pub enum CardIssuer {
diff --git a/crates/router/src/core/user_role.rs b/crates/router/src/core/user_role.rs
index 12f937280f..edad36e5aa 100644
--- a/crates/router/src/core/user_role.rs
+++ b/crates/router/src/core/user_role.rs
@@ -1,4 +1,7 @@
-use std::collections::{HashMap, HashSet};
+use std::{
+ collections::{HashMap, HashSet},
+ sync::LazyLock,
+};
use api_models::{
user as user_api,
@@ -11,7 +14,6 @@ use diesel_models::{
};
use error_stack::{report, ResultExt};
use masking::Secret;
-use once_cell::sync::Lazy;
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
@@ -51,26 +53,27 @@ pub async fn get_authorization_info_with_groups(
pub async fn get_authorization_info_with_group_tag(
) -> UserResponse<user_role_api::AuthorizationInfoResponse> {
- static GROUPS_WITH_PARENT_TAGS: Lazy<Vec<user_role_api::ParentInfo>> = Lazy::new(|| {
- PermissionGroup::iter()
- .map(|group| (group.parent(), group))
- .fold(
- HashMap::new(),
- |mut acc: HashMap<ParentGroup, Vec<PermissionGroup>>, (key, value)| {
- acc.entry(key).or_default().push(value);
- acc
- },
- )
- .into_iter()
- .filter_map(|(name, value)| {
- Some(user_role_api::ParentInfo {
- name: name.clone(),
- description: info::get_parent_group_description(name)?,
- groups: value,
+ static GROUPS_WITH_PARENT_TAGS: LazyLock<Vec<user_role_api::ParentInfo>> =
+ LazyLock::new(|| {
+ PermissionGroup::iter()
+ .map(|group| (group.parent(), group))
+ .fold(
+ HashMap::new(),
+ |mut acc: HashMap<ParentGroup, Vec<PermissionGroup>>, (key, value)| {
+ acc.entry(key).or_default().push(value);
+ acc
+ },
+ )
+ .into_iter()
+ .filter_map(|(name, value)| {
+ Some(user_role_api::ParentInfo {
+ name: name.clone(),
+ description: info::get_parent_group_description(name)?,
+ groups: value,
+ })
})
- })
- .collect()
- });
+ .collect()
+ });
Ok(ApplicationResponse::Json(
user_role_api::AuthorizationInfoResponse(
diff --git a/crates/router/src/services/authorization/roles/predefined_roles.rs b/crates/router/src/services/authorization/roles/predefined_roles.rs
index 0fce440ca6..e6bf85e157 100644
--- a/crates/router/src/services/authorization/roles/predefined_roles.rs
+++ b/crates/router/src/services/authorization/roles/predefined_roles.rs
@@ -1,12 +1,11 @@
-use std::collections::HashMap;
+use std::{collections::HashMap, sync::LazyLock};
use common_enums::{EntityType, PermissionGroup, RoleScope};
-use once_cell::sync::Lazy;
use super::RoleInfo;
use crate::consts;
-pub static PREDEFINED_ROLES: Lazy<HashMap<&'static str, RoleInfo>> = Lazy::new(|| {
+pub static PREDEFINED_ROLES: LazyLock<HashMap<&'static str, RoleInfo>> = LazyLock::new(|| {
let mut roles = HashMap::new();
// Internal Roles
diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rs
index 45eb094053..90af10ba53 100644
--- a/crates/router/src/types/domain/user.rs
+++ b/crates/router/src/types/domain/user.rs
@@ -2,6 +2,7 @@ use std::{
collections::HashSet,
ops::{Deref, Not},
str::FromStr,
+ sync::LazyLock,
};
use api_models::{
@@ -21,7 +22,6 @@ use diesel_models::{
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::api::ApplicationResponse;
use masking::{ExposeInterface, PeekInterface, Secret};
-use once_cell::sync::Lazy;
use rand::distributions::{Alphanumeric, DistString};
use time::PrimitiveDateTime;
use unicode_segmentation::UnicodeSegmentation;
@@ -90,7 +90,7 @@ impl TryFrom<pii::Email> for UserName {
#[derive(Clone, Debug)]
pub struct UserEmail(pii::Email);
-static BLOCKED_EMAIL: Lazy<HashSet<String>> = Lazy::new(|| {
+static BLOCKED_EMAIL: LazyLock<HashSet<String>> = LazyLock::new(|| {
let blocked_emails_content = include_str!("../../utils/user/blocker_emails.txt");
let blocked_emails: HashSet<String> = blocked_emails_content
.lines()
diff --git a/crates/router/src/types/domain/user/user_authentication_method.rs b/crates/router/src/types/domain/user/user_authentication_method.rs
index 29c588f15e..e1a4dd6cab 100644
--- a/crates/router/src/types/domain/user/user_authentication_method.rs
+++ b/crates/router/src/types/domain/user/user_authentication_method.rs
@@ -1,9 +1,10 @@
+use std::sync::LazyLock;
+
use common_enums::{Owner, UserAuthType};
use diesel_models::UserAuthenticationMethod;
-use once_cell::sync::Lazy;
-pub static DEFAULT_USER_AUTH_METHOD: Lazy<UserAuthenticationMethod> =
- Lazy::new(|| UserAuthenticationMethod {
+pub static DEFAULT_USER_AUTH_METHOD: LazyLock<UserAuthenticationMethod> =
+ LazyLock::new(|| UserAuthenticationMethod {
id: String::from("hyperswitch_default"),
auth_id: String::from("hyperswitch"),
owner_id: String::from("hyperswitch"),
diff --git a/crates/router/src/utils/currency.rs b/crates/router/src/utils/currency.rs
index cd56382985..aaabc9ffc2 100644
--- a/crates/router/src/utils/currency.rs
+++ b/crates/router/src/utils/currency.rs
@@ -1,11 +1,15 @@
-use std::{collections::HashMap, ops::Deref, str::FromStr, sync::Arc};
+use std::{
+ collections::HashMap,
+ ops::Deref,
+ str::FromStr,
+ sync::{Arc, LazyLock},
+};
use api_models::enums;
use common_utils::{date_time, errors::CustomResult, events::ApiEventMetric, ext_traits::AsyncExt};
use currency_conversion::types::{CurrencyFactors, ExchangeRates};
use error_stack::ResultExt;
use masking::PeekInterface;
-use once_cell::sync::Lazy;
use redis_interface::DelReply;
use router_env::{instrument, tracing};
use rust_decimal::Decimal;
@@ -32,8 +36,8 @@ pub struct FxExchangeRatesCacheEntry {
timestamp: i64,
}
-static FX_EXCHANGE_RATES_CACHE: Lazy<RwLock<Option<FxExchangeRatesCacheEntry>>> =
- Lazy::new(|| RwLock::new(None));
+static FX_EXCHANGE_RATES_CACHE: LazyLock<RwLock<Option<FxExchangeRatesCacheEntry>>> =
+ LazyLock::new(|| RwLock::new(None));
impl ApiEventMetric for FxExchangeRatesCacheEntry {}
diff --git a/crates/router_env/Cargo.toml b/crates/router_env/Cargo.toml
index 8a3482a0ac..fda230185f 100644
--- a/crates/router_env/Cargo.toml
+++ b/crates/router_env/Cargo.toml
@@ -12,7 +12,6 @@ cargo_metadata = "0.18.1"
config = { version = "0.14.0", features = ["toml"] }
error-stack = "0.4.1"
gethostname = "0.4.3"
-once_cell = "1.19.0"
opentelemetry = { version = "0.27.1", default-features = false, features = ["internal-logs", "metrics", "trace"] }
opentelemetry-aws = { version = "0.15.0", default-features = false, features = ["internal-logs", "trace"] }
opentelemetry-otlp = { version = "0.27.0", default-features = false, features = ["grpc-tonic", "metrics", "trace"] }
diff --git a/crates/router_env/src/lib.rs b/crates/router_env/src/lib.rs
index 9b3aec4c94..7d67dfc14f 100644
--- a/crates/router_env/src/lib.rs
+++ b/crates/router_env/src/lib.rs
@@ -17,7 +17,6 @@ pub mod vergen;
// pub use literally;
#[doc(inline)]
pub use logger::*;
-pub use once_cell;
pub use opentelemetry;
pub use tracing;
#[cfg(feature = "actix_web")]
diff --git a/crates/router_env/src/logger/formatter.rs b/crates/router_env/src/logger/formatter.rs
index bbcf1e2306..8e64f744fb 100644
--- a/crates/router_env/src/logger/formatter.rs
+++ b/crates/router_env/src/logger/formatter.rs
@@ -4,10 +4,10 @@ use std::{
collections::{HashMap, HashSet},
fmt,
io::Write,
+ sync::LazyLock,
};
use config::ConfigError;
-use once_cell::sync::Lazy;
use serde::ser::{SerializeMap, Serializer};
use serde_json::{ser::Formatter, Value};
// use time::format_description::well_known::Rfc3339;
@@ -54,7 +54,7 @@ const GLOBAL_ID: &str = "global_id";
const SESSION_ID: &str = "session_id";
/// Set of predefined implicit keys.
-pub static IMPLICIT_KEYS: Lazy<rustc_hash::FxHashSet<&str>> = Lazy::new(|| {
+pub static IMPLICIT_KEYS: LazyLock<rustc_hash::FxHashSet<&str>> = LazyLock::new(|| {
let mut set = rustc_hash::FxHashSet::default();
set.insert(HOSTNAME);
@@ -76,7 +76,7 @@ pub static IMPLICIT_KEYS: Lazy<rustc_hash::FxHashSet<&str>> = Lazy::new(|| {
/// Extra implicit keys. Keys that are not purely implicit but need to be logged alongside
/// other implicit keys in the log json.
-pub static EXTRA_IMPLICIT_KEYS: Lazy<rustc_hash::FxHashSet<&str>> = Lazy::new(|| {
+pub static EXTRA_IMPLICIT_KEYS: LazyLock<rustc_hash::FxHashSet<&str>> = LazyLock::new(|| {
let mut set = rustc_hash::FxHashSet::default();
set.insert(MESSAGE);
diff --git a/crates/router_env/src/metrics.rs b/crates/router_env/src/metrics.rs
index 9a7efff049..e65364651c 100644
--- a/crates/router_env/src/metrics.rs
+++ b/crates/router_env/src/metrics.rs
@@ -6,12 +6,12 @@
#[macro_export]
macro_rules! global_meter {
($name:ident) => {
- static $name: once_cell::sync::Lazy<$crate::opentelemetry::metrics::Meter> =
- once_cell::sync::Lazy::new(|| $crate::opentelemetry::global::meter(stringify!($name)));
+ static $name: ::std::sync::LazyLock<$crate::opentelemetry::metrics::Meter> =
+ ::std::sync::LazyLock::new(|| $crate::opentelemetry::global::meter(stringify!($name)));
};
($meter:ident, $name:literal) => {
- static $meter: once_cell::sync::Lazy<$crate::opentelemetry::metrics::Meter> =
- once_cell::sync::Lazy::new(|| $crate::opentelemetry::global::meter(stringify!($name)));
+ static $meter: ::std::sync::LazyLock<$crate::opentelemetry::metrics::Meter> =
+ ::std::sync::LazyLock::new(|| $crate::opentelemetry::global::meter(stringify!($name)));
};
}
@@ -23,15 +23,15 @@ macro_rules! global_meter {
#[macro_export]
macro_rules! counter_metric {
($name:ident, $meter:ident) => {
- pub(crate) static $name: once_cell::sync::Lazy<
+ pub(crate) static $name: ::std::sync::LazyLock<
$crate::opentelemetry::metrics::Counter<u64>,
- > = once_cell::sync::Lazy::new(|| $meter.u64_counter(stringify!($name)).build());
+ > = ::std::sync::LazyLock::new(|| $meter.u64_counter(stringify!($name)).build());
};
($name:ident, $meter:ident, description:literal) => {
#[doc = $description]
- pub(crate) static $name: once_cell::sync::Lazy<
+ pub(crate) static $name: ::std::sync::LazyLock<
$crate::opentelemetry::metrics::Counter<u64>,
- > = once_cell::sync::Lazy::new(|| {
+ > = ::std::sync::LazyLock::new(|| {
$meter
.u64_counter(stringify!($name))
.with_description($description)
@@ -48,9 +48,9 @@ macro_rules! counter_metric {
#[macro_export]
macro_rules! histogram_metric_f64 {
($name:ident, $meter:ident) => {
- pub(crate) static $name: once_cell::sync::Lazy<
+ pub(crate) static $name: ::std::sync::LazyLock<
$crate::opentelemetry::metrics::Histogram<f64>,
- > = once_cell::sync::Lazy::new(|| {
+ > = ::std::sync::LazyLock::new(|| {
$meter
.f64_histogram(stringify!($name))
.with_boundaries($crate::metrics::f64_histogram_buckets())
@@ -59,9 +59,9 @@ macro_rules! histogram_metric_f64 {
};
($name:ident, $meter:ident, $description:literal) => {
#[doc = $description]
- pub(crate) static $name: once_cell::sync::Lazy<
+ pub(crate) static $name: ::std::sync::LazyLock<
$crate::opentelemetry::metrics::Histogram<f64>,
- > = once_cell::sync::Lazy::new(|| {
+ > = ::std::sync::LazyLock::new(|| {
$meter
.f64_histogram(stringify!($name))
.with_description($description)
@@ -79,9 +79,9 @@ macro_rules! histogram_metric_f64 {
#[macro_export]
macro_rules! histogram_metric_u64 {
($name:ident, $meter:ident) => {
- pub(crate) static $name: once_cell::sync::Lazy<
+ pub(crate) static $name: ::std::sync::LazyLock<
$crate::opentelemetry::metrics::Histogram<u64>,
- > = once_cell::sync::Lazy::new(|| {
+ > = ::std::sync::LazyLock::new(|| {
$meter
.u64_histogram(stringify!($name))
.with_boundaries($crate::metrics::f64_histogram_buckets())
@@ -90,9 +90,9 @@ macro_rules! histogram_metric_u64 {
};
($name:ident, $meter:ident, $description:literal) => {
#[doc = $description]
- pub(crate) static $name: once_cell::sync::Lazy<
+ pub(crate) static $name: ::std::sync::LazyLock<
$crate::opentelemetry::metrics::Histogram<u64>,
- > = once_cell::sync::Lazy::new(|| {
+ > = ::std::sync::LazyLock::new(|| {
$meter
.u64_histogram(stringify!($name))
.with_description($description)
@@ -110,13 +110,13 @@ macro_rules! histogram_metric_u64 {
#[macro_export]
macro_rules! gauge_metric {
($name:ident, $meter:ident) => {
- pub(crate) static $name: once_cell::sync::Lazy<$crate::opentelemetry::metrics::Gauge<u64>> =
- once_cell::sync::Lazy::new(|| $meter.u64_gauge(stringify!($name)).build());
+ pub(crate) static $name: ::std::sync::LazyLock<$crate::opentelemetry::metrics::Gauge<u64>> =
+ ::std::sync::LazyLock::new(|| $meter.u64_gauge(stringify!($name)).build());
};
($name:ident, $meter:ident, description:literal) => {
#[doc = $description]
- pub(crate) static $name: once_cell::sync::Lazy<$crate::opentelemetry::metrics::Gauge<u64>> =
- once_cell::sync::Lazy::new(|| {
+ pub(crate) static $name: ::std::sync::LazyLock<$crate::opentelemetry::metrics::Gauge<u64>> =
+ ::std::sync::LazyLock::new(|| {
$meter
.u64_gauge(stringify!($name))
.with_description($description)
diff --git a/crates/router_env/tests/logger.rs b/crates/router_env/tests/logger.rs
index 1070938a8a..84831b221a 100644
--- a/crates/router_env/tests/logger.rs
+++ b/crates/router_env/tests/logger.rs
@@ -8,9 +8,9 @@ use router_env::TelemetryGuard;
use self::test_module::fn_with_colon;
fn logger() -> error_stack::Result<&'static TelemetryGuard, ConfigError> {
- use once_cell::sync::OnceCell;
+ use std::sync::OnceLock;
- static INSTANCE: OnceCell<TelemetryGuard> = OnceCell::new();
+ static INSTANCE: OnceLock<TelemetryGuard> = OnceLock::new();
Ok(INSTANCE.get_or_init(|| {
let config = router_env::Config::new().unwrap();
diff --git a/crates/scheduler/Cargo.toml b/crates/scheduler/Cargo.toml
index 5c2bc868ab..07599a9885 100644
--- a/crates/scheduler/Cargo.toml
+++ b/crates/scheduler/Cargo.toml
@@ -19,7 +19,6 @@ async-trait = "0.1.79"
error-stack = "0.4.1"
futures = "0.3.30"
num_cpus = "1.16.0"
-once_cell = "1.19.0"
rand = "0.8.5"
serde = "1.0.197"
serde_json = "1.0.115"
diff --git a/crates/storage_impl/Cargo.toml b/crates/storage_impl/Cargo.toml
index ad712565b5..ee849f78f4 100644
--- a/crates/storage_impl/Cargo.toml
+++ b/crates/storage_impl/Cargo.toml
@@ -43,7 +43,6 @@ dyn-clone = "1.0.17"
error-stack = "0.4.1"
futures = "0.3.30"
moka = { version = "0.12", features = ["future"] }
-once_cell = "1.19.0"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
thiserror = "1.0.58"
diff --git a/crates/storage_impl/src/redis/cache.rs b/crates/storage_impl/src/redis/cache.rs
index fb752e64b0..538d7c8c94 100644
--- a/crates/storage_impl/src/redis/cache.rs
+++ b/crates/storage_impl/src/redis/cache.rs
@@ -1,4 +1,9 @@
-use std::{any::Any, borrow::Cow, fmt::Debug, sync::Arc};
+use std::{
+ any::Any,
+ borrow::Cow,
+ fmt::Debug,
+ sync::{Arc, LazyLock},
+};
use common_utils::{
errors::{self, CustomResult},
@@ -7,7 +12,6 @@ use common_utils::{
use dyn_clone::DynClone;
use error_stack::{Report, ResultExt};
use moka::future::Cache as MokaCache;
-use once_cell::sync::Lazy;
use redis_interface::{errors::RedisError, RedisConnectionPool, RedisValue};
use router_env::{
logger,
@@ -33,19 +37,19 @@ const CACHE_TTI: u64 = 10 * 60;
const MAX_CAPACITY: u64 = 30;
/// Config Cache with time_to_live as 30 mins and time_to_idle as 10 mins.
-pub static CONFIG_CACHE: Lazy<Cache> =
- Lazy::new(|| Cache::new("CONFIG_CACHE", CACHE_TTL, CACHE_TTI, None));
+pub static CONFIG_CACHE: LazyLock<Cache> =
+ LazyLock::new(|| Cache::new("CONFIG_CACHE", CACHE_TTL, CACHE_TTI, None));
/// Accounts cache with time_to_live as 30 mins and size limit
-pub static ACCOUNTS_CACHE: Lazy<Cache> =
- Lazy::new(|| Cache::new("ACCOUNTS_CACHE", CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
+pub static ACCOUNTS_CACHE: LazyLock<Cache> =
+ LazyLock::new(|| Cache::new("ACCOUNTS_CACHE", CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
/// Routing Cache
-pub static ROUTING_CACHE: Lazy<Cache> =
- Lazy::new(|| Cache::new("ROUTING_CACHE", CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
+pub static ROUTING_CACHE: LazyLock<Cache> =
+ LazyLock::new(|| Cache::new("ROUTING_CACHE", CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
/// 3DS Decision Manager Cache
-pub static DECISION_MANAGER_CACHE: Lazy<Cache> = Lazy::new(|| {
+pub static DECISION_MANAGER_CACHE: LazyLock<Cache> = LazyLock::new(|| {
Cache::new(
"DECISION_MANAGER_CACHE",
CACHE_TTL,
@@ -55,15 +59,15 @@ pub static DECISION_MANAGER_CACHE: Lazy<Cache> = Lazy::new(|| {
});
/// Surcharge Cache
-pub static SURCHARGE_CACHE: Lazy<Cache> =
- Lazy::new(|| Cache::new("SURCHARGE_CACHE", CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
+pub static SURCHARGE_CACHE: LazyLock<Cache> =
+ LazyLock::new(|| Cache::new("SURCHARGE_CACHE", CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
/// CGraph Cache
-pub static CGRAPH_CACHE: Lazy<Cache> =
- Lazy::new(|| Cache::new("CGRAPH_CACHE", CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
+pub static CGRAPH_CACHE: LazyLock<Cache> =
+ LazyLock::new(|| Cache::new("CGRAPH_CACHE", CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
/// PM Filter CGraph Cache
-pub static PM_FILTERS_CGRAPH_CACHE: Lazy<Cache> = Lazy::new(|| {
+pub static PM_FILTERS_CGRAPH_CACHE: LazyLock<Cache> = LazyLock::new(|| {
Cache::new(
"PM_FILTERS_CGRAPH_CACHE",
CACHE_TTL,
@@ -73,7 +77,7 @@ pub static PM_FILTERS_CGRAPH_CACHE: Lazy<Cache> = Lazy::new(|| {
});
/// Success based Dynamic Algorithm Cache
-pub static SUCCESS_BASED_DYNAMIC_ALGORITHM_CACHE: Lazy<Cache> = Lazy::new(|| {
+pub static SUCCESS_BASED_DYNAMIC_ALGORITHM_CACHE: LazyLock<Cache> = LazyLock::new(|| {
Cache::new(
"SUCCESS_BASED_DYNAMIC_ALGORITHM_CACHE",
CACHE_TTL,
@@ -83,7 +87,7 @@ pub static SUCCESS_BASED_DYNAMIC_ALGORITHM_CACHE: Lazy<Cache> = Lazy::new(|| {
});
/// Elimination based Dynamic Algorithm Cache
-pub static ELIMINATION_BASED_DYNAMIC_ALGORITHM_CACHE: Lazy<Cache> = Lazy::new(|| {
+pub static ELIMINATION_BASED_DYNAMIC_ALGORITHM_CACHE: LazyLock<Cache> = LazyLock::new(|| {
Cache::new(
"ELIMINATION_BASED_DYNAMIC_ALGORITHM_CACHE",
CACHE_TTL,
@@ -93,7 +97,7 @@ pub static ELIMINATION_BASED_DYNAMIC_ALGORITHM_CACHE: Lazy<Cache> = Lazy::new(||
});
/// Contract Routing based Dynamic Algorithm Cache
-pub static CONTRACT_BASED_DYNAMIC_ALGORITHM_CACHE: Lazy<Cache> = Lazy::new(|| {
+pub static CONTRACT_BASED_DYNAMIC_ALGORITHM_CACHE: LazyLock<Cache> = LazyLock::new(|| {
Cache::new(
"CONTRACT_BASED_DYNAMIC_ALGORITHM_CACHE",
CACHE_TTL,