36 lines
1.0 KiB
Rust
36 lines
1.0 KiB
Rust
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,
|
|
});
|
|
}
|
|
}
|