feat: increment RPM counter before request forwarding

This commit is contained in:
QTom
2026-02-28 01:25:50 +08:00
parent 678c3ae132
commit f648b8e026
2 changed files with 23 additions and 0 deletions

View File

@@ -2241,6 +2241,15 @@ func (s *GatewayService) isAccountSchedulableForRPM(ctx context.Context, account
return true
}
// IncrementAccountRPM increments the RPM counter for the given account.
func (s *GatewayService) IncrementAccountRPM(ctx context.Context, accountID int64) error {
if s.rpmCache == nil {
return nil
}
_, err := s.rpmCache.IncrementRPM(ctx, accountID)
return err
}
// checkAndRegisterSession 检查并注册会话,用于会话数量限制
// 仅适用于 Anthropic OAuth/SetupToken 账号
// sessionID: 会话标识符(使用粘性会话的 hash