mirror of https://github.com/mastodon/flodgatt
32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
use super::{deployment_cfg_types::*, EnvVar};
|
|
|
|
#[derive(Debug, Default)]
|
|
pub struct DeploymentConfig<'a> {
|
|
pub env: Env,
|
|
pub log_level: LogLevel,
|
|
pub address: FlodgattAddr,
|
|
pub port: Port,
|
|
pub unix_socket: Socket,
|
|
pub cors: Cors<'a>,
|
|
pub sse_interval: SseInterval,
|
|
pub ws_interval: WsInterval,
|
|
}
|
|
|
|
impl DeploymentConfig<'_> {
|
|
pub fn from_env(env: EnvVar) -> Self {
|
|
let mut cfg = Self {
|
|
env: Env::default().maybe_update(env.get("NODE_ENV")),
|
|
log_level: LogLevel::default().maybe_update(env.get("RUST_LOG")),
|
|
address: FlodgattAddr::default().maybe_update(env.get("BIND")),
|
|
port: Port::default().maybe_update(env.get("PORT")),
|
|
unix_socket: Socket::default().maybe_update(env.get("SOCKET")),
|
|
sse_interval: SseInterval::default().maybe_update(env.get("SSE_FREQ")),
|
|
ws_interval: WsInterval::default().maybe_update(env.get("WS_FREQ")),
|
|
cors: Cors::default(),
|
|
};
|
|
cfg.env = cfg.env.maybe_update(env.get("RUST_ENV"));
|
|
log::info!("Using deployment configuration:\n {:#?}", &cfg);
|
|
cfg
|
|
}
|
|
}
|