domain: add Processing entities and ports (Job, JobBatch, Plugin, Pipeline)
This commit is contained in:
35
crates/domain/src/entities/processing_pipeline.rs
Normal file
35
crates/domain/src/entities/processing_pipeline.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use crate::value_objects::{StructuredData, SystemId};
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct PipelineStep {
|
||||
pub plugin_id: SystemId,
|
||||
pub step_order: u32,
|
||||
pub configuration: StructuredData,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ProcessingPipeline {
|
||||
pub pipeline_id: SystemId,
|
||||
pub trigger_event: String,
|
||||
pub steps: Vec<PipelineStep>,
|
||||
}
|
||||
|
||||
impl ProcessingPipeline {
|
||||
pub fn new(trigger_event: impl Into<String>) -> Self {
|
||||
Self {
|
||||
pipeline_id: SystemId::new(),
|
||||
trigger_event: trigger_event.into(),
|
||||
steps: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_step(&mut self, plugin_id: SystemId, config: StructuredData) {
|
||||
let next_order = self.steps.iter().map(|s| s.step_order).max().unwrap_or(0)
|
||||
+ if self.steps.is_empty() { 0 } else { 1 };
|
||||
self.steps.push(PipelineStep {
|
||||
plugin_id,
|
||||
step_order: next_order,
|
||||
configuration: config,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user