pinakes-server: integrate plugin system into routes & application state
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ib5d482326cae1dcb43603bffb76a6a186a6a6964
This commit is contained in:
parent
f686e8a777
commit
e9c5390c45
6 changed files with 206 additions and 46 deletions
|
|
@ -5,7 +5,7 @@ use pinakes_core::{
|
|||
config::Config,
|
||||
jobs::JobQueue,
|
||||
managed_storage::ManagedStorageService,
|
||||
plugin::PluginManager,
|
||||
plugin::{PluginManager, PluginPipeline},
|
||||
scan::ScanProgress,
|
||||
scheduler::TaskScheduler,
|
||||
storage::DynStorageBackend,
|
||||
|
|
@ -32,9 +32,23 @@ pub struct AppState {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue