apalis_workflow/sequential/
router.rs1use std::{collections::HashMap, time::Duration};
2
3use apalis_core::{
4 backend::{Backend, WireFormatBackend},
5 task::task_id::TaskId,
6};
7use serde::{Deserialize, Serialize};
8
9use crate::SteppedService;
10
11#[derive(Debug, Default)]
13pub struct WorkflowRouter<B>
14where
15 B: Backend + WireFormatBackend,
16{
17 pub(crate) steps: HashMap<usize, SteppedService<B::Compact>>,
18}
19
20impl<B> WorkflowRouter<B>
21where
22 B: Backend + WireFormatBackend,
23{
24 #[must_use]
26 pub fn new() -> Self {
27 Self {
28 steps: HashMap::new(),
29 }
30 }
31}
32#[derive(Debug, Clone, Deserialize, Serialize)]
34pub struct StepResponse {
35 pub result: serde_json::Value,
37 pub next_task_id: Option<TaskId>,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43#[non_exhaustive]
44pub enum GoTo<T = ()> {
45 Next(T),
47 DelayFor(Duration, T),
49 Break(T),
51 Done,
53}