Skip to main content

aion_server/config/
runtime.rs

1//! Runtime-facing config views: [`RuntimeConfig`] and [`CliOverrides`].
2//!
3//! [`RuntimeConfig`] is the non-secret runtime slice carried in shared server
4//! state for transport adapters (produced by [`ServerConfig::into_parts`]);
5//! [`CliOverrides`] is the command-line override bundle merged after file and
6//! environment values. Both are re-exported from the `config` module so every
7//! existing `crate::config::X` path resolves identically.
8//!
9//! [`ServerConfig::into_parts`]: super::ServerConfig::into_parts
10
11use std::{net::SocketAddr, path::PathBuf, time::Duration};
12
13use super::{
14    AuthConfig, AuthoringConfig, AutoCreate, DeployConfig, DevConfig, ListenConfig, MetricsConfig,
15    NamespaceConfig, ObservabilityConfig, OpsConsoleConfig, OutboxConfig, TlsConfig,
16    WebSocketConfig, WorkerConfig,
17};
18
19/// Command-line configuration overrides applied after file and environment values.
20#[derive(Debug, Default)]
21pub struct CliOverrides {
22    /// Optional explicit config path from `--config`.
23    pub config_path: Option<PathBuf>,
24    /// Override for `[server].listen_address`.
25    pub listen_address: Option<SocketAddr>,
26    /// Override for `[store].url`.
27    pub store_url: Option<String>,
28    /// Override for `[runtime].scheduler_threads`.
29    pub scheduler_threads: Option<usize>,
30    /// Override for `[drain].timeout_seconds`.
31    pub drain_timeout_seconds: Option<u64>,
32    /// Additional workflow package archives loaded after config and auto-discovered packages.
33    pub workflow_packages: Vec<PathBuf>,
34    /// Override for `[authoring].gleam_path`: the external `gleam` binary that
35    /// gates the server-side authoring loop. Setting it commissions the
36    /// authoring endpoints.
37    pub gleam_path: Option<PathBuf>,
38    /// Override for `[authoring].project_root`: the built Gleam workflow
39    /// project submitted source is written into and packaged from.
40    pub authoring_project_root: Option<PathBuf>,
41}
42
43/// Runtime settings retained in shared server state for transport adapters.
44#[derive(Clone, Debug)]
45pub struct RuntimeConfig {
46    /// Listener addresses for public transports.
47    pub listen: ListenConfig,
48    /// Optional TLS material for public transports.
49    pub tls: Option<TlsConfig>,
50    /// Authentication configuration shared by transports.
51    pub auth: AuthConfig,
52    /// Ops-console asset location.
53    pub ops_console: OpsConsoleConfig,
54    /// Namespace resolver construction mode.
55    pub namespace: NamespaceConfig,
56    /// Remote worker heartbeat configuration.
57    pub worker: WorkerConfig,
58    /// WebSocket stream configuration.
59    pub websocket: WebSocketConfig,
60    /// Workflow package archives loaded into the engine at startup.
61    pub workflow_packages: Vec<PathBuf>,
62    /// Operator deploy API settings.
63    pub deploy: DeployConfig,
64    /// Server-side Gleam authoring API settings.
65    pub authoring: AuthoringConfig,
66    /// Local dev-server surface settings.
67    pub dev: DevConfig,
68    /// Durable-outbox fan-out dispatcher settings.
69    pub outbox: OutboxConfig,
70    /// Agent-observability transcript retention bounds (`[observability]`).
71    pub observability: ObservabilityConfig,
72    /// Engine scheduler thread count.
73    pub scheduler_threads: usize,
74    /// Engine reply deadline for workflow queries. REQUIRED — carried as an
75    /// [`Option`] only so state construction can re-validate (defense in
76    /// depth, like `websocket.event_broadcast_capacity`); validated
77    /// configurations always hold [`Some`] non-zero duration.
78    pub query_timeout: Option<Duration>,
79    /// Default namespace used by worker dispatch and unauthenticated local callers.
80    pub default_namespace: String,
81    /// Minted-on-use policy applied at the worker-registration mint hook
82    /// (`[namespaces] auto_create`). [`AutoCreate::Open`] (the default) mints an
83    /// unseen namespace durably; [`AutoCreate::Closed`] rejects it.
84    pub auto_create: AutoCreate,
85    /// Platform-wide default for a namespace's cluster-wide concurrent
86    /// in-flight-activity ceiling (`[namespaces] max_in_flight_activities`),
87    /// applied when a namespace record carries no explicit override. Carried in
88    /// runtime state so the later P2-Q2 keyed-backpressure dispatcher can read
89    /// it without reloading config. Stored-only in this slice — nothing reads it
90    /// yet.
91    pub max_in_flight_activities: u32,
92    /// Graceful drain timeout.
93    pub drain_timeout: Duration,
94    /// Metrics endpoint settings.
95    pub metrics: MetricsConfig,
96    /// Static distribution-shard assignment for this node (from `[store]
97    /// owned_shards`). Empty means own ALL shards (single-node default,
98    /// byte-identical to today); a non-empty set scopes engine recovery and
99    /// enumeration to exactly those shards. No election: assignment is static.
100    pub owned_shards: Vec<usize>,
101    /// Browser origins allowed cross-origin access to the public HTTP API (from
102    /// `[server] cors_allowed_origins`). Empty means no cross-origin access and
103    /// no `CorsLayer` is installed (secure default); a non-empty set installs
104    /// the layer scoped to exactly those origins.
105    pub cors_allowed_origins: Vec<String>,
106}