mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
feat: 自适应 RPM 未学习时不限制,改为碰壁学习策略
- 移除自适应模式的默认初始限制(RPMDefaults.INITIAL_LIMIT) - 未学习到边界前不限制 RPM,让系统自由运行直到遇到 429 - 前端自适应 Key 显示学习到的值或"探测中"状态 - 批量余额查询改为并行执行,提升性能
This commit is contained in:
@@ -599,7 +599,7 @@ class ProviderOpsService:
|
||||
self, provider_ids: Optional[List[str]] = None
|
||||
) -> Dict[str, ActionResult]:
|
||||
"""
|
||||
批量查询余额
|
||||
批量查询余额(优先返回缓存,后台异步刷新)
|
||||
|
||||
Args:
|
||||
provider_ids: Provider ID 列表,None 表示查询所有已配置的
|
||||
@@ -616,9 +616,24 @@ class ProviderOpsService:
|
||||
if p.config and p.config.get("provider_ops")
|
||||
]
|
||||
|
||||
# 并行查询,使用缓存优先策略
|
||||
tasks = [
|
||||
self.query_balance_with_cache(provider_id, trigger_refresh=True)
|
||||
for provider_id in provider_ids
|
||||
]
|
||||
results_list = await asyncio.gather(*tasks, return_exceptions=True)
|
||||
|
||||
results = {}
|
||||
for provider_id in provider_ids:
|
||||
results[provider_id] = await self.query_balance(provider_id)
|
||||
for provider_id, result in zip(provider_ids, results_list):
|
||||
if isinstance(result, Exception):
|
||||
logger.warning(f"查询余额失败: provider_id={provider_id}, error={result}")
|
||||
results[provider_id] = ActionResult(
|
||||
status=ActionStatus.UNKNOWN_ERROR,
|
||||
action_type=ProviderActionType.QUERY_BALANCE,
|
||||
message=str(result),
|
||||
)
|
||||
else:
|
||||
results[provider_id] = result
|
||||
|
||||
return results
|
||||
|
||||
|
||||
Reference in New Issue
Block a user