//! Shared application state handed to every router via Topcoat's app context. use std::path::PathBuf; use std::sync::Arc; use forge_core::{Config, Store}; use forge_git::GitEnv; use tokio::sync::Notify; use crate::throttle::Throttle; #[derive(Clone)] pub struct AppState { pub config: Arc, pub store: Store, pub git: Arc, /// Instance secret key (data_dir/forge.key). Signs private raw-file URLs. pub key: Arc<[u8; 32]>, /// Random per boot. Presented by hook processes on the internal API. pub internal_token: Arc, /// Per boot. Presented by the CLI on the `/internal/admin/*` routes. Also written to /// `data_dir/run/admin.token` with mode 0600, which is how the CLI reads it. pub admin_token: Arc, /// The single backup and fsck run slot of this process. pub jobs: Arc, /// Absolute path to the internal unix socket (data_dir/internal.sock). pub internal_socket: PathBuf, /// Failed-authentication counters for login and git HTTP. Shared by every request. pub throttle: Arc, /// Wakes the webhook delivery worker when a delivery is queued. pub webhook_waker: Arc, /// Wakes the mirror worker on "sync now" and after a push to a repo with push mirrors. pub mirror_waker: Arc, /// Release asset bytes under `data_dir/blobs`. pub blobs: crate::blobs::BlobStore, /// Standby replication queue: repos to push after a ref update, and the reconcile-now flag. pub replication: Arc, /// Wakes long-polling runner claims when a CI job becomes Queued. pub ci_waker: Arc, /// Outgoing mail transport: SMTP, or the log transport in dev and tests. pub mailer: Arc, /// Wakes the mail worker when a message is queued or the mail settings change. pub mail_waker: Arc, }