1use std::collections::HashMap;
4use std::net::IpAddr;
5use std::path::PathBuf;
6use std::sync::Arc;
7use std::time::Instant;
8
9use tokio::sync::{broadcast, Mutex, RwLock};
10use tokio_util::sync::CancellationToken;
11use tuitbot_core::automation::circuit_breaker::CircuitBreaker;
12use tuitbot_core::automation::Runtime;
13use tuitbot_core::config::{ContentSourcesConfig, DeploymentMode};
14use tuitbot_core::content::ContentGenerator;
15use tuitbot_core::storage::DbPool;
16
17use crate::ws::WsEvent;
18
19pub struct AppState {
21 pub db: DbPool,
23 pub config_path: PathBuf,
25 pub data_dir: PathBuf,
27 pub event_tx: broadcast::Sender<WsEvent>,
29 pub api_token: String,
31 pub passphrase_hash: RwLock<Option<String>>,
33 pub bind_host: String,
35 pub bind_port: u16,
37 pub login_attempts: Mutex<HashMap<IpAddr, (u32, Instant)>>,
39 pub runtimes: Mutex<HashMap<String, Runtime>>,
41 pub content_generators: Mutex<HashMap<String, Arc<ContentGenerator>>>,
43 pub circuit_breaker: Option<Arc<CircuitBreaker>>,
45 pub watchtower_cancel: Option<CancellationToken>,
47 pub content_sources: ContentSourcesConfig,
49 pub deployment_mode: DeploymentMode,
51}