1use devsper_core::{GraphSnapshot, NodeId};
2use devsper_graph::GraphHandle;
3
4pub struct Scheduler {
7 handle: GraphHandle,
8}
9
10impl Scheduler {
11 pub fn new(handle: GraphHandle) -> Self {
12 Self { handle }
13 }
14
15 pub async fn get_ready(&self) -> Vec<NodeId> {
17 self.handle.get_ready().await
18 }
19
20 pub async fn claim(&self, id: NodeId) -> bool {
22 self.handle.claim(id).await
23 }
24
25 pub async fn complete(&self, id: NodeId, result: serde_json::Value) {
27 self.handle.complete(id, result).await;
28 }
29
30 pub async fn fail(&self, id: NodeId, error: String) {
32 self.handle.fail(id, error).await;
33 }
34
35 pub async fn snapshot(&self) -> Option<GraphSnapshot> {
37 self.handle.snapshot().await
38 }
39
40 pub fn handle(&self) -> &GraphHandle {
42 &self.handle
43 }
44}