use tower_resilience_core::ResilienceError;
#[derive(Debug, Clone, thiserror::Error)]
pub enum BulkheadError {
#[error("bulkhead is full: max concurrent calls ({max_concurrent_calls}) reached")]
BulkheadFull {
max_concurrent_calls: usize,
},
#[error("timeout waiting for bulkhead permit")]
Timeout,
}
pub type Result<T> = std::result::Result<T, BulkheadError>;
impl<E> From<BulkheadError> for ResilienceError<E> {
fn from(err: BulkheadError) -> Self {
match err {
BulkheadError::Timeout => ResilienceError::Timeout { layer: "bulkhead" },
BulkheadError::BulkheadFull {
max_concurrent_calls,
} => ResilienceError::BulkheadFull {
concurrent_calls: max_concurrent_calls,
max_concurrent: max_concurrent_calls,
},
}
}
}