use std::{collections::HashMap, time::Duration};
use apalis_core::{
backend::{Backend, WireFormatBackend},
task::task_id::TaskId,
};
use serde::{Deserialize, Serialize};
use crate::SteppedService;
#[derive(Debug, Default)]
pub struct WorkflowRouter<B>
where
B: Backend + WireFormatBackend,
{
pub(crate) steps: HashMap<usize, SteppedService<B::Compact>>,
}
impl<B> WorkflowRouter<B>
where
B: Backend + WireFormatBackend,
{
#[must_use]
pub fn new() -> Self {
Self {
steps: HashMap::new(),
}
}
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct StepResponse {
pub result: serde_json::Value,
pub next_task_id: Option<TaskId>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GoTo<T = ()> {
Next(T),
DelayFor(Duration, T),
Break(T),
Done,
}