pub struct AppState {
pub smtp: SmtpTransport,
pub rate_limiter: Arc<RateLimiter>,
pub metrics: Arc<Metrics>,
pub status_store: Arc<dyn StatusStore>,
/* private fields */
}Expand description
Shared application state, cloned into every Axum request via Arc.
config is wrapped in ArcSwap for atomic hot-swap on SIGHUP (RFC 305).
All code accesses config via state.config(), which returns a snapshot
Arc<AppConfig> valid for the lifetime of one request.
Fields§
§smtp: SmtpTransport§rate_limiter: Arc<RateLimiter>§metrics: Arc<Metrics>§status_store: Arc<dyn StatusStore>Submission status store (RFC 086/087).
Implementations§
Source§impl AppState
impl AppState
Sourcepub fn config(&self) -> Arc<AppConfig>
pub fn config(&self) -> Arc<AppConfig>
Load a snapshot of the current config.
Returns an Arc<AppConfig> that remains valid even if a concurrent
SIGHUP reload replaces the stored config.
Sourcepub fn new_with_store(
config: AppConfig,
store: Arc<dyn StatusStore>,
) -> Arc<Self>
pub fn new_with_store( config: AppConfig, store: Arc<dyn StatusStore>, ) -> Arc<Self>
Create an AppState with a pre-built status store (useful for tests and SQLite).
Sourcepub fn reload_config(&self, new_config: AppConfig)
pub fn reload_config(&self, new_config: AppConfig)
Replace the stored config atomically (called on SIGHUP, RFC 305).
SIGHUP-reloadable status fields: ttl_seconds, max_records, cleanup_interval_seconds.
Apply SIGHUP reload. Restart-required fields that changed cause a warning
and are ignored — only reloadable fields take effect (RFC 811).