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