Expand description
Bulkhead policy for concurrency limiting.
The bulkhead policy limits the number of concurrent executions, preventing resource exhaustion and isolating failures.
§Examples
use do_over::{policy::Policy, bulkhead::Bulkhead, error::DoOverError};
use std::time::Duration;
// Allow maximum 10 concurrent executions
let bulkhead = Bulkhead::new(10);
// With queue timeout - wait up to 1 second for a slot
let bulkhead = Bulkhead::new(10)
.with_queue_timeout(Duration::from_secs(1));
match bulkhead.execute(|| async {
Ok::<_, DoOverError<std::io::Error>>("completed")
}).await {
Ok(result) => println!("Success: {}", result),
Err(DoOverError::BulkheadFull) => println!("No capacity available"),
Err(e) => println!("Error: {:?}", e),
}Structs§
- Bulkhead
- A policy that limits concurrent executions.