mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-05 00:47:48 +08:00
Clarify API key concurrency skip reasons
This commit is contained in:
@@ -32,7 +32,9 @@ use sha2::{Digest, Sha256};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub(crate) use self::selection::{
|
||||
SchedulerSkippedCandidate, API_KEY_CONCURRENCY_LIMIT_SKIP_REASON,
|
||||
is_auth_api_key_concurrency_limit_skip_reason, SchedulerSkippedCandidate,
|
||||
API_KEY_CONCURRENCY_LIMIT_SKIP_REASON, AUTH_API_KEY_CONCURRENCY_LIMIT_SKIP_REASON,
|
||||
LEGACY_API_KEY_CONCURRENCY_LIMIT_SKIP_REASON,
|
||||
};
|
||||
|
||||
use crate::data::auth::GatewayAuthApiKeySnapshot;
|
||||
|
||||
@@ -20,7 +20,19 @@ pub(crate) struct SchedulerSkippedCandidate {
|
||||
pub(crate) skip_reason: &'static str,
|
||||
}
|
||||
|
||||
pub(crate) const API_KEY_CONCURRENCY_LIMIT_SKIP_REASON: &str = "api_key_concurrency_limit_reached";
|
||||
pub(crate) const AUTH_API_KEY_CONCURRENCY_LIMIT_SKIP_REASON: &str =
|
||||
"auth_api_key_concurrency_limit_reached";
|
||||
pub(crate) const LEGACY_API_KEY_CONCURRENCY_LIMIT_SKIP_REASON: &str =
|
||||
"api_key_concurrency_limit_reached";
|
||||
pub(crate) const API_KEY_CONCURRENCY_LIMIT_SKIP_REASON: &str =
|
||||
AUTH_API_KEY_CONCURRENCY_LIMIT_SKIP_REASON;
|
||||
|
||||
pub(crate) fn is_auth_api_key_concurrency_limit_skip_reason(reason: &str) -> bool {
|
||||
matches!(
|
||||
reason.trim(),
|
||||
AUTH_API_KEY_CONCURRENCY_LIMIT_SKIP_REASON | LEGACY_API_KEY_CONCURRENCY_LIMIT_SKIP_REASON
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn is_exact_all_skipped_by_auth_limit(
|
||||
selected: &[SchedulerMinimalCandidateSelectionCandidate],
|
||||
@@ -30,7 +42,7 @@ pub(super) fn is_exact_all_skipped_by_auth_limit(
|
||||
&& !skipped.is_empty()
|
||||
&& skipped
|
||||
.iter()
|
||||
.all(|candidate| candidate.skip_reason == API_KEY_CONCURRENCY_LIMIT_SKIP_REASON)
|
||||
.all(|candidate| is_auth_api_key_concurrency_limit_skip_reason(candidate.skip_reason))
|
||||
}
|
||||
|
||||
#[cfg_attr(not(test), allow(dead_code))]
|
||||
|
||||
Reference in New Issue
Block a user