refactor: Convert some things from static to const and refactor into drop-consts

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
quexeky
2025-10-13 08:59:00 +11:00
parent ef9f8caa54
commit f0e46c4a46
22 changed files with 76 additions and 47 deletions

View File

@ -8,6 +8,7 @@ bitcode = "0.6.7"
chrono = "0.4.42"
client = { version = "0.1.0", path = "../client" }
database = { version = "0.1.0", path = "../database" }
drop-consts = { version = "0.1.0", path = "../drop-consts" }
droplet-rs = "0.7.3"
gethostname = "1.0.2"
hex = "0.4.3"

View File

@ -1,10 +1,8 @@
use std::{
fs::{self, File},
io::Read,
sync::LazyLock,
cell::LazyCell, fs::{self, File}, io::Read
};
use database::db::DATA_ROOT_DIR;
use drop_consts::DATA_ROOT_DIR;
use log::{debug, info, warn};
use reqwest::Certificate;
use serde::Deserialize;
@ -19,10 +17,10 @@ impl DropHealthcheck {
&self.app_name
}
}
static DROP_CERT_BUNDLE: LazyLock<Vec<Certificate>> = LazyLock::new(fetch_certificates);
pub static DROP_CLIENT_SYNC: LazyLock<reqwest::blocking::Client> = LazyLock::new(get_client_sync);
pub static DROP_CLIENT_ASYNC: LazyLock<reqwest::Client> = LazyLock::new(get_client_async);
pub static DROP_CLIENT_WS_CLIENT: LazyLock<reqwest::Client> = LazyLock::new(get_client_ws);
const DROP_CERT_BUNDLE: LazyCell<Vec<Certificate>> = LazyCell::new(fetch_certificates);
pub const DROP_CLIENT_SYNC: LazyCell<reqwest::blocking::Client> = LazyCell::new(get_client_sync);
pub const DROP_CLIENT_ASYNC: LazyCell<reqwest::Client> = LazyCell::new(get_client_async);
pub const DROP_CLIENT_WS_CLIENT: LazyCell<reqwest::Client> = LazyCell::new(get_client_ws);
fn fetch_certificates() -> Vec<Certificate> {
let certificate_dir = DATA_ROOT_DIR.join("certificates");