Add basic models

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet
2025-08-20 14:04:08 +02:00
parent b769fa63f7
commit acf875ed33
10 changed files with 225 additions and 0 deletions

38
src/models/job.rs Normal file
View File

@@ -0,0 +1,38 @@
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::{models::ScriptType, time::Timestamp};
#[derive(Serialize, Deserialize)]
pub struct Job {
/// Job Id, this is given by the actor who created the job
id: u32,
/// Actor ID which created this job
caller_id: u32,
/// Context in which the job is executed
context_id: u32,
script: String,
script_type: ScriptType,
/// Timeout in seconds for this job
timeout: u32,
/// Max amount of times to retry this job
retries: u8,
env_vars: HashMap<String, String>,
result: HashMap<String, String>,
prerequisites: Vec<String>,
/// Ids of jobs this job depends on, i.e. this job can't start until those have finished
depends: Vec<u32>,
created_at: Timestamp,
updated_at: Timestamp,
status: JobStatus,
}
#[derive(Serialize, Deserialize)]
pub enum JobStatus {
Dispatched,
WaitingForPrerequisites,
Started,
Error,
Finished,
}