feat: dagrunner, initial version
This commit is contained in:
122 files changed
+23101
No files matched your search
@@ -0,0 +1,36 @@
|
||||
//! Runtime integration tests - verify dagx works correctly across different runtimes
|
||||
|
||||
use dagx::{DagResult, DagRunner, Task};
|
||||
|
||||
struct Value(i32);
|
||||
#[dagx::task]
|
||||
impl Value {
|
||||
async fn run(&mut self) -> i32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
struct Add;
|
||||
#[dagx::task]
|
||||
impl Add {
|
||||
async fn run(&mut self, a: &i32, b: &i32) -> i32 {
|
||||
a + b
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn runtime_integration_tokio() -> DagResult<()> {
|
||||
let dag = DagRunner::new();
|
||||
|
||||
let a = dag.add_task(Value(10));
|
||||
let b = dag.add_task(Value(20));
|
||||
let sum = dag.add_task(Add).depends_on((&a, &b));
|
||||
|
||||
dag.run(|fut| {
|
||||
tokio::spawn(fut);
|
||||
})
|
||||
.await?;
|
||||
|
||||
assert_eq!(dag.get(sum)?, 30);
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user