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