Files
herocoordinator/src/models/flow.rs
2025-08-22 14:08:41 +02:00

50 lines
1.1 KiB
Rust

use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::time::Timestamp;
#[derive(Serialize, Deserialize, Clone)]
pub struct Flow {
/// Job Id set tby the actor which created it
pub id: u32,
/// Actor Id who created this job
pub caller_id: u32,
/// The context in which this job is executed
pub context_id: u32,
/// List of jobs which make up the flow
pub jobs: Vec<u32>,
/// Environment variables, passed to every job when executed
pub env_vars: HashMap<String, String>,
/// The result of the flow
pub result: HashMap<String, String>,
pub created_at: Timestamp,
pub updated_at: Timestamp,
pub status: FlowStatus,
}
/// The status of a flow
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub enum FlowStatus {
Created,
Dispatched,
Started,
Error,
Finished,
}
impl Flow {
pub fn id(&self) -> u32 {
self.id
}
pub fn caller_id(&self) -> u32 {
self.caller_id
}
pub fn context_id(&self) -> u32 {
self.context_id
}
pub fn jobs(&self) -> &[u32] {
&self.jobs
}
}