2cdc49d7f2
Phase 1: Fix compilation (config_path Option<PathBuf>, streaming test, stale test cleanup) Phase 2: Fix critical bugs (remove block_on deadlocks in 4 providers, fix broken SQL query builder) Phase 3: Security hardening (session manager, real auth, token masking, Gemini key to header, password policy) Phase 4: Implement stubs (real provider test, /proc health metrics, client/provider/backup endpoints, has_images) Phase 5: Code quality (shared provider helpers, explicit re-exports, all Clippy warnings fixed, unwrap removal, 6 unused deps removed, dashboard split into 7 sub-modules) Phase 6: Infrastructure (GitHub Actions CI, multi-stage Dockerfile, rustfmt.toml, clippy.toml, script fixes)
49 lines
1.5 KiB
Rust
49 lines
1.5 KiB
Rust
use std::sync::Arc;
|
|
use tokio::sync::broadcast;
|
|
|
|
use crate::{
|
|
client::ClientManager, config::AppConfig, database::DbPool, logging::RequestLogger,
|
|
models::registry::ModelRegistry, providers::ProviderManager, rate_limiting::RateLimitManager,
|
|
};
|
|
|
|
/// Shared application state
|
|
#[derive(Clone)]
|
|
pub struct AppState {
|
|
pub config: Arc<AppConfig>,
|
|
pub provider_manager: ProviderManager,
|
|
pub db_pool: DbPool,
|
|
pub rate_limit_manager: Arc<RateLimitManager>,
|
|
pub client_manager: Arc<ClientManager>,
|
|
pub request_logger: Arc<RequestLogger>,
|
|
pub model_registry: Arc<ModelRegistry>,
|
|
pub dashboard_tx: broadcast::Sender<serde_json::Value>,
|
|
pub auth_tokens: Vec<String>,
|
|
}
|
|
|
|
impl AppState {
|
|
pub fn new(
|
|
config: Arc<AppConfig>,
|
|
provider_manager: ProviderManager,
|
|
db_pool: DbPool,
|
|
rate_limit_manager: RateLimitManager,
|
|
model_registry: ModelRegistry,
|
|
auth_tokens: Vec<String>,
|
|
) -> Self {
|
|
let client_manager = Arc::new(ClientManager::new(db_pool.clone()));
|
|
let (dashboard_tx, _) = broadcast::channel(100);
|
|
let request_logger = Arc::new(RequestLogger::new(db_pool.clone(), dashboard_tx.clone()));
|
|
|
|
Self {
|
|
config,
|
|
provider_manager,
|
|
db_pool,
|
|
rate_limit_manager: Arc::new(rate_limit_manager),
|
|
client_manager,
|
|
request_logger,
|
|
model_registry: Arc::new(model_registry),
|
|
dashboard_tx,
|
|
auth_tokens,
|
|
}
|
|
}
|
|
}
|