Skip to main content

apalis_workflow/graph/
response.rs

1use std::collections::HashMap;
2
3use apalis_core::task::task_id::TaskId;
4use petgraph::graph::NodeIndex;
5use serde::{Deserialize, Serialize};
6
7/// Response from Graph execution step
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
9#[non_exhaustive]
10pub enum GraphNodeResponse {
11    /// Entry nodes have been fanned out
12    EntryFanOut {
13        /// Map of node indices to their task IDs
14        node_task_ids: HashMap<NodeIndex, TaskId>,
15    },
16    /// Next tasks have been fanned out
17    FanOut {
18        /// Result of the current task
19        response: serde_json::Value,
20        /// Map of node indices to their task IDs
21        node_task_ids: HashMap<NodeIndex, TaskId>,
22    },
23    /// Next task has been enqueued
24    EnqueuedNext {
25        /// Result of the current task
26        result: serde_json::Value,
27    },
28    /// Waiting for dependencies to complete
29    WaitingForDependencies {
30        /// Map of pending dependency node indices to their task IDs
31        pending_dependencies: HashMap<NodeIndex, TaskId>,
32    },
33
34    /// Graph execution is complete
35    Complete {
36        /// Result of the final task
37        result: serde_json::Value,
38    },
39}