Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ib5d482326cae1dcb43603bffb76a6a186a6a6964
54 lines
1.7 KiB
Rust
54 lines
1.7 KiB
Rust
use std::{path::PathBuf, sync::Arc};
|
|
|
|
use pinakes_core::{
|
|
cache::CacheLayer,
|
|
config::Config,
|
|
jobs::JobQueue,
|
|
managed_storage::ManagedStorageService,
|
|
plugin::{PluginManager, PluginPipeline},
|
|
scan::ScanProgress,
|
|
scheduler::TaskScheduler,
|
|
storage::DynStorageBackend,
|
|
sync::ChunkedUploadManager,
|
|
transcode::TranscodeService,
|
|
webhooks::WebhookDispatcher,
|
|
};
|
|
use tokio::sync::{RwLock, Semaphore};
|
|
|
|
// Note: Sessions are now stored in the database via StorageBackend
|
|
// See storage::SessionData and related methods
|
|
|
|
/// Max concurrent background session operations (touch/delete).
|
|
/// Prevents unbounded task spawning under high request load.
|
|
pub const MAX_SESSION_BACKGROUND_TASKS: usize = 64;
|
|
|
|
#[derive(Clone)]
|
|
pub struct AppState {
|
|
pub storage: DynStorageBackend,
|
|
pub config: Arc<RwLock<Config>>,
|
|
pub config_path: Option<PathBuf>,
|
|
pub scan_progress: ScanProgress,
|
|
pub job_queue: Arc<JobQueue>,
|
|
pub cache: Arc<CacheLayer>,
|
|
pub scheduler: Arc<TaskScheduler>,
|
|
pub plugin_manager: Option<Arc<PluginManager>>,
|
|
pub plugin_pipeline: Option<Arc<PluginPipeline>>,
|
|
pub transcode_service: Option<Arc<TranscodeService>>,
|
|
pub managed_storage: Option<Arc<ManagedStorageService>>,
|
|
pub chunked_upload_manager: Option<Arc<ChunkedUploadManager>>,
|
|
pub webhook_dispatcher: Option<Arc<WebhookDispatcher>>,
|
|
pub session_semaphore: Arc<Semaphore>,
|
|
}
|
|
|
|
impl AppState {
|
|
/// Emit a plugin event if the pipeline is active.
|
|
pub fn emit_plugin_event(
|
|
&self,
|
|
event_type: &str,
|
|
payload: &serde_json::Value,
|
|
) {
|
|
if let Some(ref pipeline) = self.plugin_pipeline {
|
|
pipeline.emit_event(event_type, payload);
|
|
}
|
|
}
|
|
}
|