mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
fix: 修复并发计数器在请求异常时不能正确减少的问题
- 增强事件监听机制 - 监听 req 的 close 和 aborted 事件 - 监听 res 的 finish 和 error 事件 - 使用标志位确保只减少一次计数 - 改进日志记录 - 增加并发计数增减的详细日志 - 记录请求关闭和中断事件 - 确保计数器安全性 - 使用 Lua 脚本原子操作防止负数 - 优化 Redis 操作逻辑 - 增强管理界面 - API Keys 列表显示当前并发数 - 并发数超过 0 时用橙色标记 - 显示当前并发数/限制数格式 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -132,12 +132,13 @@ class ApiKeyService {
|
||||
try {
|
||||
const apiKeys = await redis.getAllApiKeys();
|
||||
|
||||
// 为每个key添加使用统计
|
||||
// 为每个key添加使用统计和当前并发数
|
||||
for (const key of apiKeys) {
|
||||
key.usage = await redis.getUsageStats(key.id);
|
||||
key.tokenLimit = parseInt(key.tokenLimit);
|
||||
key.requestLimit = parseInt(key.requestLimit);
|
||||
key.concurrencyLimit = parseInt(key.concurrencyLimit || 0);
|
||||
key.currentConcurrency = await redis.getConcurrency(key.id);
|
||||
key.isActive = key.isActive === 'true';
|
||||
delete key.apiKey; // 不返回哈希后的key
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user