refactor(rate_limit): refactor API Key rate limiting and remove tenant-level QPS check
- Streamline rate limit check flow by removing redundant tenant-level QPS checks. - Restrict checks to API Key QPS and plan degradation protection only. - Update constant naming and error message handling for consistency.
This commit is contained in:
@@ -108,8 +108,7 @@ def require_api_key(
|
||||
# 根据错误消息判断限流类型
|
||||
if "Daily" in error_msg:
|
||||
code = BizCode.API_KEY_DAILY_LIMIT_EXCEEDED
|
||||
elif "QPS" in error_msg or "ops rate limit" in error_msg:
|
||||
# "QPS limit exceeded" 和 "API ops rate limit exceeded" 同属 QPS 类
|
||||
elif "QPS" in error_msg:
|
||||
code = BizCode.API_KEY_QPS_LIMIT_EXCEEDED
|
||||
else:
|
||||
code = BizCode.API_KEY_QUOTA_EXCEEDED
|
||||
|
||||
@@ -18,7 +18,7 @@ from app.core.quota_manager import (
|
||||
get_quota_usage,
|
||||
_check_quota,
|
||||
QuotaUsageRepository,
|
||||
TENANT_QPS_REDIS_KEY,
|
||||
API_KEY_QPS_REDIS_KEY,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
@@ -34,5 +34,5 @@ __all__ = [
|
||||
"get_quota_usage",
|
||||
"_check_quota",
|
||||
"QuotaUsageRepository",
|
||||
"TENANT_QPS_REDIS_KEY",
|
||||
"API_KEY_QPS_REDIS_KEY",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user