mobius_gateway/config/
runtime.rs1use crate::{Error, Result};
4
5mobius::embedded_config! {
6 copy;
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub struct RuntimeConfig {
10 pub idle_exit_seconds: u64,
12 pub storage_limit_bytes: Option<u64>,
14 pub ingress: Option<std::net::SocketAddr>,
16 pub require_access_lease: bool,
18 pub access_grace_seconds: u64,
20}
21 defaults = include_str!("runtime.toml");
22}
23
24impl RuntimeConfig {
25 pub(super) fn validate(&self) -> Result<()> {
26 super::bounded(
27 "runtime.idle_exit_seconds",
28 self.idle_exit_seconds,
29 0..=31_536_000,
30 )?;
31 super::bounded(
32 "runtime.access_grace_seconds",
33 self.access_grace_seconds,
34 0..=86_400,
35 )?;
36 if self
37 .storage_limit_bytes
38 .is_some_and(|limit| limit < 64 * 1024 * 1024)
39 {
40 return Err(Error::Config(
41 "storage_limit_bytes must be at least 64 MiB".into(),
42 ));
43 }
44 Ok(())
45 }
46}