chorus/src/globals.rs
2024-02-17 09:53:47 +13:00

29 lines
696 B
Rust

use crate::config::Config;
use crate::store::Store;
use hyper::server::conn::Http;
use lazy_static::lazy_static;
use std::sync::OnceLock;
use tokio::sync::RwLock;
pub struct Globals {
pub config: RwLock<Config>,
pub store: OnceLock<Store>,
pub http_server: Http,
pub rid: OnceLock<String>,
}
lazy_static! {
pub static ref GLOBALS: Globals = {
let mut http_server = hyper::server::conn::Http::new();
http_server.http1_only(true);
http_server.http1_keep_alive(true);
Globals {
config: RwLock::new(Config::default()),
store: OnceLock::new(),
http_server,
rid: OnceLock::new(),
}
};
}