Files
k-tv/crates/playout/src/config.rs

35 lines
1.1 KiB
Rust

use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct PlayoutConfig {
pub listen_addr: String,
pub segment_duration_secs: u32,
pub window_size: usize,
pub storage_path: PathBuf,
pub tick_interval_ms: u64,
}
impl PlayoutConfig {
pub fn from_env() -> Self {
Self {
listen_addr: std::env::var("PLAYOUT_LISTEN_ADDR")
.unwrap_or_else(|_| "0.0.0.0:9090".into()),
segment_duration_secs: std::env::var("PLAYOUT_SEGMENT_DURATION")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(6),
window_size: std::env::var("PLAYOUT_WINDOW_SIZE")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(10),
storage_path: std::env::var("PLAYOUT_STORAGE_PATH")
.map(PathBuf::from)
.unwrap_or_else(|_| PathBuf::from("/tmp/k-tv-playout")),
tick_interval_ms: std::env::var("PLAYOUT_TICK_INTERVAL_MS")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(1000),
}
}
}