apalis_workflow/
router.rs1use std::{collections::HashMap, time::Duration};
2
3use apalis_core::{backend::BackendExt, task::task_id::TaskId};
4use serde::{Deserialize, Serialize};
5
6use crate::SteppedService;
7
8#[derive(Debug, Default)]
10pub struct WorkflowRouter<Backend>
11where
12 Backend: BackendExt,
13{
14 pub(super) steps:
15 HashMap<usize, SteppedService<Backend::Compact, Backend::Context, Backend::IdType>>,
16}
17
18impl<Backend> WorkflowRouter<Backend>
19where
20 Backend: BackendExt,
21{
22 #[must_use]
24 pub fn new() -> Self {
25 Self {
26 steps: HashMap::new(),
27 }
28 }
29}
30#[derive(Debug, Clone, Deserialize, Serialize, Default)]
32pub struct StepResult<Res, IdType> {
33 pub result: Res,
35 pub next_task_id: Option<TaskId<IdType>>,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41pub enum GoTo<T = ()> {
42 Next(T),
44 DelayFor(Duration, T),
46 Break(T),
48 Done,
50}