use devsper_core::{GraphSnapshot, NodeId};
use devsper_graph::GraphHandle;
pub struct Scheduler {
handle: GraphHandle,
}
impl Scheduler {
pub fn new(handle: GraphHandle) -> Self {
Self { handle }
}
pub async fn get_ready(&self) -> Vec<NodeId> {
self.handle.get_ready().await
}
pub async fn claim(&self, id: NodeId) -> bool {
self.handle.claim(id).await
}
pub async fn complete(&self, id: NodeId, result: serde_json::Value) {
self.handle.complete(id, result).await;
}
pub async fn fail(&self, id: NodeId, error: String) {
self.handle.fail(id, error).await;
}
pub async fn snapshot(&self) -> Option<GraphSnapshot> {
self.handle.snapshot().await
}
pub fn handle(&self) -> &GraphHandle {
&self.handle
}
}