feat(quota): refactor quota management and rate limiting services
- Add `API_KEY_RATE_LIMIT_EXCEEDED` error code. - Refactor `QuotaExceededError` to support resource type localization. - Optimize rate limiting service by implementing the sliding window algorithm. - Add rate limit validation for tenant plans. - Unify quota check decorator to support both synchronous and asynchronous operations. - Enhance quota usage statistics endpoints.
This commit is contained in:
@@ -106,7 +106,7 @@
|
||||
},
|
||||
"api": {
|
||||
"rate_limit_exceeded": "API rate limit exceeded",
|
||||
"quota_exceeded": "API quota exceeded",
|
||||
"quota_exceeded": "{resource} quota exceeded",
|
||||
"invalid_api_key": "Invalid API key",
|
||||
"api_key_expired": "API key has expired",
|
||||
"api_key_revoked": "API key has been revoked",
|
||||
@@ -114,7 +114,8 @@
|
||||
"method_not_allowed": "Method not allowed",
|
||||
"invalid_request": "Invalid request",
|
||||
"missing_parameter": "Missing required parameter: {param}",
|
||||
"invalid_parameter": "Invalid parameter: {param}"
|
||||
"invalid_parameter": "Invalid parameter: {param}",
|
||||
"api_key_rate_limit_exceeded": "API Key rate limit ({rate_limit}) exceeds tenant plan limit ({limit})"
|
||||
},
|
||||
"database": {
|
||||
"connection_failed": "Database connection failed",
|
||||
@@ -134,5 +135,16 @@
|
||||
"invalid_format": "Invalid format: {field}",
|
||||
"invalid_value": "Invalid value: {field}",
|
||||
"out_of_range": "Value out of range: {field}"
|
||||
},
|
||||
"quota_resources": {
|
||||
"workspace": "Workspace",
|
||||
"app": "App",
|
||||
"skill": "Skill",
|
||||
"knowledge_capacity": "Knowledge capacity",
|
||||
"memory_engine": "Memory engine",
|
||||
"end_user": "End user",
|
||||
"model": "Model",
|
||||
"ontology_project": "Ontology project",
|
||||
"api_ops_rate_limit": "API ops rate limit"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
},
|
||||
"api": {
|
||||
"rate_limit_exceeded": "API调用频率超限",
|
||||
"quota_exceeded": "API调用配额已用完",
|
||||
"quota_exceeded": "{resource} 配额已超限",
|
||||
"invalid_api_key": "无效的API密钥",
|
||||
"api_key_expired": "API密钥已过期",
|
||||
"api_key_revoked": "API密钥已被撤销",
|
||||
@@ -114,7 +114,8 @@
|
||||
"method_not_allowed": "不支持的请求方法",
|
||||
"invalid_request": "无效的请求",
|
||||
"missing_parameter": "缺少必需参数:{param}",
|
||||
"invalid_parameter": "参数无效:{param}"
|
||||
"invalid_parameter": "参数无效:{param}",
|
||||
"api_key_rate_limit_exceeded": "API Key 的 QPS 限制({rate_limit})超过租户套餐上限({limit})"
|
||||
},
|
||||
"database": {
|
||||
"connection_failed": "数据库连接失败",
|
||||
@@ -134,5 +135,16 @@
|
||||
"invalid_format": "格式不正确:{field}",
|
||||
"invalid_value": "值无效:{field}",
|
||||
"out_of_range": "值超出范围:{field}"
|
||||
},
|
||||
"quota_resources": {
|
||||
"workspace": "工作空间",
|
||||
"app": "应用",
|
||||
"skill": "技能",
|
||||
"knowledge_capacity": "知识库容量",
|
||||
"memory_engine": "记忆引擎",
|
||||
"end_user": "终端用户",
|
||||
"model": "模型",
|
||||
"ontology_project": "本体工程",
|
||||
"api_ops_rate_limit": "API 操作速率"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user