mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-12 06:00:20 +08:00
Add usage queue worker autoscaling
This commit is contained in:
@@ -20,6 +20,15 @@ pub fn provider_auto_remove_banned_keys(config: Option<&serde_json::Value>) -> b
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn provider_auto_remove_quota_exhausted_keys(config: Option<&serde_json::Value>) -> bool {
|
||||
config
|
||||
.and_then(|value| value.get("pool_advanced"))
|
||||
.and_then(serde_json::Value::as_object)
|
||||
.and_then(|object| object.get("auto_remove_quota_exhausted_keys"))
|
||||
.and_then(serde_json::Value::as_bool)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn should_auto_remove_structured_reason(reason: Option<&str>) -> bool {
|
||||
provider_status::should_auto_remove_account_state(&provider_status::resolve_pool_account_state(
|
||||
None, None, reason,
|
||||
@@ -1767,13 +1776,30 @@ mod tests {
|
||||
parse_codex_wham_usage_response, parse_gemini_cli_retrieve_user_quota_response,
|
||||
parse_gemini_cli_v1internal_credits_response, parse_windsurf_model_configs_response,
|
||||
parse_windsurf_rate_limit_response, parse_windsurf_user_status_response,
|
||||
quota_refresh_success_invalid_state, should_auto_remove_structured_reason,
|
||||
OAUTH_ACCOUNT_BLOCK_PREFIX, OAUTH_EXPIRED_PREFIX, OAUTH_REFRESH_FAILED_PREFIX,
|
||||
OAUTH_REQUEST_FAILED_PREFIX,
|
||||
provider_auto_remove_quota_exhausted_keys, quota_refresh_success_invalid_state,
|
||||
should_auto_remove_structured_reason, OAUTH_ACCOUNT_BLOCK_PREFIX, OAUTH_EXPIRED_PREFIX,
|
||||
OAUTH_REFRESH_FAILED_PREFIX, OAUTH_REQUEST_FAILED_PREFIX,
|
||||
};
|
||||
use aether_data_contracts::repository::provider_catalog::StoredProviderCatalogKey;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn provider_auto_remove_quota_exhausted_keys_defaults_to_false() {
|
||||
assert!(!provider_auto_remove_quota_exhausted_keys(None));
|
||||
assert!(!provider_auto_remove_quota_exhausted_keys(Some(&json!({
|
||||
"pool_advanced": {}
|
||||
}))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn provider_auto_remove_quota_exhausted_keys_reads_pool_advanced_flag() {
|
||||
assert!(provider_auto_remove_quota_exhausted_keys(Some(&json!({
|
||||
"pool_advanced": {
|
||||
"auto_remove_quota_exhausted_keys": true
|
||||
}
|
||||
}))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_runtime_invalid_reason_marks_401_as_expired() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user