Depend on futures-util instead of futures

This commit is contained in:
TechnoPorg committed 2026-02-11 22:44:01 +01:00
1 parent f342e33f16
commit a75defa5a6
79 files changed
+447 -380

No files matched your search

+20 -9
View File
@@ -2,7 +2,7 @@
use crate::common::task_fn;
use dagx::{DagResult, DagRunner};
use futures::FutureExt;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;
@@ -24,7 +24,9 @@ async fn test_fallback_on_error() -> DagResult<()> {
let _selector = dag.add_task(task_fn::<(), _, _>(|_: ()| {}));
// Run DAG
let _ = dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await;
let _ = dag
.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await;
// Primary should fail
assert!(dag.get(primary).is_err());
@@ -58,7 +60,8 @@ async fn test_retry_pattern_simulation() -> DagResult<()> {
}
}));
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
// Task completes with error on first "attempt"
assert_eq!(dag.get(task)?, Err("Simulated failure"));
@@ -99,7 +102,8 @@ async fn test_circuit_breaker_pattern() -> DagResult<()> {
})
.collect();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
// First few tasks fail and open circuit
for task in tasks.into_iter().take(4) {
@@ -131,7 +135,9 @@ async fn test_partial_recovery_with_defaults() -> DagResult<()> {
vec![0, 10, 20, 0, 40, 50, 0, 70, 80, 0] // 0 for failed tasks
}));
let _ = dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await;
let _ = dag
.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await;
let result = dag.get(aggregator)?;
assert_eq!(result.len(), 10);
@@ -159,7 +165,8 @@ async fn test_error_accumulation_pattern() -> DagResult<()> {
})
.collect();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
// Check accumulated errors
let error_list = errors.lock().clone();
@@ -197,7 +204,8 @@ async fn test_graceful_degradation() -> DagResult<()> {
}))
.depends_on(critical);
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
// Critical path works
assert_eq!(dag.get(final_task)?, 15);
@@ -228,7 +236,8 @@ async fn test_error_boundary_isolation() -> DagResult<()> {
.add_task(task_fn::<i32, _, _>(|&x: &i32| x + 5))
.depends_on(b2);
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
// Group A fails (returns Err)
assert_eq!(dag.get(a2)?, Err("Group A error"));
@@ -261,7 +270,9 @@ async fn test_compensation_action() -> DagResult<()> {
}
}));
let _ = dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await;
let _ = dag
.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await;
// Action failed
assert!(dag.get(action).is_err());