更新配置

This commit is contained in:
Hua
2025-02-19 08:46:26 +08:00
parent e0b133ea1e
commit 7ec5abe67f
3 changed files with 21 additions and 5 deletions

View File

@ -18,6 +18,7 @@ var (
mu sync.RWMutex
aiBalancer *AIBalancer
balancerMu sync.RWMutex
)
type Config struct {
@ -332,7 +333,16 @@ func (b *AIBalancer) Next() (*AIConfig, error) {
return &highPriorityAIs[0], nil
}
// 添加获取 AIBalancer 的方法
// ResetAIBalancer 重置 AI 负载均衡器
func ResetAIBalancer(ais []AIConfig) {
balancerMu.Lock()
defer balancerMu.Unlock()
aiBalancer = NewAIBalancer(ais)
}
// GetAIBalancer 获取当前的 AI 负载均衡器
func GetAIBalancer() *AIBalancer {
balancerMu.RLock()
defer balancerMu.RUnlock()
return aiBalancer
}