41 lines
1.5 KiB
Rust
41 lines
1.5 KiB
Rust
use async_trait::async_trait;
|
|
use crate::common::errors::DomainError;
|
|
use crate::common::value_objects::SystemId;
|
|
use super::entities::{Job, JobBatch, Plugin, ProcessingPipeline};
|
|
|
|
// --- JobRepository ---
|
|
|
|
#[async_trait]
|
|
pub trait JobRepository: Send + Sync {
|
|
async fn find_by_id(&self, id: &SystemId) -> Result<Option<Job>, DomainError>;
|
|
async fn find_next_queued(&self) -> Result<Option<Job>, DomainError>;
|
|
async fn find_by_batch(&self, batch_id: &SystemId) -> Result<Vec<Job>, DomainError>;
|
|
async fn save(&self, job: &Job) -> Result<(), DomainError>;
|
|
}
|
|
|
|
// --- JobBatchRepository ---
|
|
|
|
#[async_trait]
|
|
pub trait JobBatchRepository: Send + Sync {
|
|
async fn find_by_id(&self, id: &SystemId) -> Result<Option<JobBatch>, DomainError>;
|
|
async fn save(&self, batch: &JobBatch) -> Result<(), DomainError>;
|
|
}
|
|
|
|
// --- PluginRepository ---
|
|
|
|
#[async_trait]
|
|
pub trait PluginRepository: Send + Sync {
|
|
async fn find_by_id(&self, id: &SystemId) -> Result<Option<Plugin>, DomainError>;
|
|
async fn find_enabled(&self) -> Result<Vec<Plugin>, DomainError>;
|
|
async fn save(&self, plugin: &Plugin) -> Result<(), DomainError>;
|
|
}
|
|
|
|
// --- PipelineRepository ---
|
|
|
|
#[async_trait]
|
|
pub trait PipelineRepository: Send + Sync {
|
|
async fn find_by_id(&self, id: &SystemId) -> Result<Option<ProcessingPipeline>, DomainError>;
|
|
async fn find_by_trigger(&self, event: &str) -> Result<Vec<ProcessingPipeline>, DomainError>;
|
|
async fn save(&self, pipeline: &ProcessingPipeline) -> Result<(), DomainError>;
|
|
}
|