Skip to main content

orbit_client_pool/
error.rs

1use std::time::Duration;
2
3/// Invalid client-pool options.
4#[derive(Debug, thiserror::Error, Eq, PartialEq)]
5pub enum OptionsError {
6    #[error("client pool max_live must be greater than zero")]
7    ZeroMaxLive,
8    #[error("client pool max_concurrency must be greater than zero")]
9    ZeroMaxConcurrency,
10    #[error(
11        "fleet client pool requires an Orbit pool spec with fleet concurrency enabled"
12    )]
13    FleetConcurrencyDisabled,
14    #[error(
15        "client pool capacity must satisfy min_idle <= max_idle <= max_live; got {min_idle} <= {max_idle} <= {max_live}"
16    )]
17    CapacityOrder { min_idle: usize, max_idle: usize, max_live: usize },
18    #[error("client pool attempts must be greater than zero")]
19    ZeroAttempts,
20    #[error("client pool {0} must be greater than zero when present")]
21    ZeroDuration(&'static str),
22}
23
24/// Failure to acquire one client.
25#[derive(Debug, thiserror::Error)]
26pub enum AcquireError<E> {
27    #[error("client pool is closed")]
28    Closed,
29    #[error("client pool wait queue is full (maximum {max_waiting})")]
30    QueueFull { max_waiting: usize },
31    #[error("client pool is at its physical capacity")]
32    AtCapacity,
33    #[error("timed out acquiring a client after {0:?}")]
34    Timeout(Duration),
35    #[error("client acquisition was cancelled")]
36    Cancelled,
37    #[error("client manager failed: {0}")]
38    Manager(#[source] E),
39}