heldar_entry/config.rs
1//! The access-control app's own configuration, loaded from the environment by the composing server. The open
2//! kernel does not carry any entry-app tuning knobs.
3
4fn parse_or<T: std::str::FromStr>(key: &str, default: T) -> T {
5 std::env::var(key)
6 .ok()
7 .filter(|s| !s.trim().is_empty())
8 .and_then(|v| v.parse().ok())
9 .unwrap_or(default)
10}
11
12#[derive(Clone, Debug)]
13pub struct EntryConfig {
14 /// Minimum reads agreeing on a track's winning plate before the ANPR engine commits an entry
15 /// event (temporal voting). Lower = faster but noisier; higher = more accurate but more latency.
16 pub anpr_min_votes: u32,
17 /// How long entry events (+ their evidence frames) are kept before this app's retention prunes them.
18 pub entry_retention_days: i64,
19}
20
21impl EntryConfig {
22 pub fn from_env() -> Self {
23 EntryConfig {
24 anpr_min_votes: parse_or::<u32>("HELDAR_ANPR_MIN_VOTES", 3).clamp(1, 50),
25 entry_retention_days: parse_or("HELDAR_ENTRY_RETENTION_DAYS", 365),
26 }
27 }
28}