use at_shared::config::AppConfig; use sqlx::PgPool; use std::sync::Arc; use crate::auth::PdsKeys; use crate::firehose::Stats; #[derive(Clone)] pub struct AppState { pub cfg: AppConfig, pub db: PgPool, pub stats: Arc, /// Cache of the PDS's published signing key, used by the /// [`crate::auth::AuthedDid`] extractor. Shared (`Arc`) so every /// handler verifies against the same cached key and one HTTP /// client, and so a key rotation picked up by one request is /// immediately visible to the rest. pub pds_keys: Arc, } impl AppState { pub fn new(cfg: AppConfig, db: PgPool, stats: Arc) -> Self { let pds_keys = Arc::new(PdsKeys::from_config(&cfg)); Self { cfg, db, stats, pds_keys, } } }