mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-29 16:00:51 +00:00
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:
@@ -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.",
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.",
|
||||||
|
|||||||
Reference in New Issue
Block a user