fix(core): remove the queue error dependency cycle (#789)

Co-authored-by: Zyy <zyycn@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Zyy
2026-11-28 17:07:55 +08:00
committed by GitHub
co-authored by Zyy Codex
parent 7633a62368
commit 3ec00a152c
2 changed files with 18 additions and 14 deletions
@@ -408,14 +408,8 @@ impl QueueRejection {
#[must_use] #[must_use]
pub fn gateway_error(self) -> crate::error::GatewayError { pub fn gateway_error(self) -> crate::error::GatewayError {
match self { match self {
Self::Full => crate::error::GatewayError::new( Self::Full => crate::error::GatewayError::concurrency_queue_full(),
crate::error::GatewayErrorKind::ConcurrencyQueueFull, Self::Timeout => crate::error::GatewayError::concurrency_queue_timeout(),
"The gateway request queue is full.",
),
Self::Timeout => crate::error::GatewayError::new(
crate::error::GatewayErrorKind::ConcurrencyQueueTimeout,
"The request timed out in the gateway queue.",
),
} }
} }
} }
+16 -6
View File
@@ -1381,6 +1381,20 @@ impl GatewayError {
} }
} }
pub(crate) const fn concurrency_queue_full() -> Self {
Self::new(
GatewayErrorKind::ConcurrencyQueueFull,
"The gateway request queue is full.",
)
}
pub(crate) const fn concurrency_queue_timeout() -> Self {
Self::new(
GatewayErrorKind::ConcurrencyQueueTimeout,
"The request timed out in the gateway queue.",
)
}
#[must_use] #[must_use]
pub fn with_source(mut self, source: impl Into<ErrorSource>) -> Self { pub fn with_source(mut self, source: impl Into<ErrorSource>) -> Self {
self.source = Some(source.into()); self.source = Some(source.into());
@@ -1469,12 +1483,8 @@ impl GatewayError {
GatewayErrorKind::AccountPoolQuotaExhausted, GatewayErrorKind::AccountPoolQuotaExhausted,
"No eligible gateway account has quota for this request.", "No eligible gateway account has quota for this request.",
), ),
ProviderErrorKind::ConcurrencyQueueFull => { ProviderErrorKind::ConcurrencyQueueFull => Self::concurrency_queue_full(),
crate::concurrency::QueueRejection::Full.gateway_error() ProviderErrorKind::ConcurrencyQueueTimeout => Self::concurrency_queue_timeout(),
}
ProviderErrorKind::ConcurrencyQueueTimeout => {
crate::concurrency::QueueRejection::Timeout.gateway_error()
}
ProviderErrorKind::AccountCapacityUnavailable => Self::new( ProviderErrorKind::AccountCapacityUnavailable => Self::new(
GatewayErrorKind::AccountCapacityUnavailable, GatewayErrorKind::AccountCapacityUnavailable,
"The gateway account pool is busy.", "The gateway account pool is busy.",