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]
pub fn gateway_error(self) -> crate::error::GatewayError {
match self {
Self::Full => crate::error::GatewayError::new(
crate::error::GatewayErrorKind::ConcurrencyQueueFull,
"The gateway request queue is full.",
),
Self::Timeout => crate::error::GatewayError::new(
crate::error::GatewayErrorKind::ConcurrencyQueueTimeout,
"The request timed out in the gateway queue.",
),
Self::Full => crate::error::GatewayError::concurrency_queue_full(),
Self::Timeout => crate::error::GatewayError::concurrency_queue_timeout(),
}
}
}
+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]
pub fn with_source(mut self, source: impl Into<ErrorSource>) -> Self {
self.source = Some(source.into());
@@ -1469,12 +1483,8 @@ impl GatewayError {
GatewayErrorKind::AccountPoolQuotaExhausted,
"No eligible gateway account has quota for this request.",
),
ProviderErrorKind::ConcurrencyQueueFull => {
crate::concurrency::QueueRejection::Full.gateway_error()
}
ProviderErrorKind::ConcurrencyQueueTimeout => {
crate::concurrency::QueueRejection::Timeout.gateway_error()
}
ProviderErrorKind::ConcurrencyQueueFull => Self::concurrency_queue_full(),
ProviderErrorKind::ConcurrencyQueueTimeout => Self::concurrency_queue_timeout(),
ProviderErrorKind::AccountCapacityUnavailable => Self::new(
GatewayErrorKind::AccountCapacityUnavailable,
"The gateway account pool is busy.",