feat: publish sanitized custom.97 source

This commit is contained in:
cneicy committed 2026-10-27 20:43:39 +08:00
1 parent 8e6ed0317b
commit 86c0276156
1022 files changed
+69903 -19207

No files matched your search

+10 -11
View File
@@ -1,7 +1,6 @@
package service
import (
"fmt"
"hash/fnv"
"maps"
"regexp"
@@ -146,7 +145,7 @@ func GetChannelAffinityCacheStats() ChannelAffinityCacheStats {
keys, err := cache.Keys()
if err != nil {
common.SysError(fmt.Sprintf("channel affinity cache list keys failed: err=%v", err))
common.SysError(common.LogText("channel affinity cache list keys failed: err=%v", err))
keys = nil
}
total := len(keys)
@@ -202,12 +201,12 @@ func ClearChannelAffinityCacheAll() int {
cache := getChannelAffinityCache()
keys, err := cache.Keys()
if err != nil {
common.SysError(fmt.Sprintf("channel affinity cache list keys failed: err=%v", err))
common.SysError(common.LogText("channel affinity cache list keys failed: err=%v", err))
keys = nil
}
if len(keys) > 0 {
if _, err := cache.DeleteMany(keys); err != nil {
common.SysError(fmt.Sprintf("channel affinity cache delete many failed: err=%v", err))
common.SysError(common.LogText("channel affinity cache delete many failed: err=%v", err))
}
}
return len(keys)
@@ -216,12 +215,12 @@ func ClearChannelAffinityCacheAll() int {
func ClearChannelAffinityCacheByRuleName(ruleName string) (int, error) {
ruleName = strings.TrimSpace(ruleName)
if ruleName == "" {
return 0, fmt.Errorf("rule_name 不能为空")
return 0, common.NewMessage("rule_name cannot be empty")
}
setting := operation_setting.GetChannelAffinitySetting()
if setting == nil {
return 0, fmt.Errorf("channel_affinity_setting 未初始化")
return 0, common.NewMessage("Channel affinity settings are not initialized")
}
var matchedRule *operation_setting.ChannelAffinityRule
@@ -234,10 +233,10 @@ func ClearChannelAffinityCacheByRuleName(ruleName string) (int, error) {
break
}
if matchedRule == nil {
return 0, fmt.Errorf("未知规则名称")
return 0, common.NewMessage("Unknown rule name")
}
if !matchedRule.IncludeRuleName {
return 0, fmt.Errorf("该规则未启用 include_rule_name,无法按规则清空缓存")
return 0, common.NewMessage("This rule does not have include_rule_name enabled, so its cache cannot be cleared by rule")
}
cache := getChannelAffinityCache()
@@ -620,7 +619,7 @@ func GetPreferredChannelByAffinity(c *gin.Context, modelName string, usingGroup
cache := getChannelAffinityCache()
channelID, found, err := cache.Get(cacheKeySuffix)
if err != nil {
common.SysError(fmt.Sprintf("channel affinity cache get failed: key=%s, err=%v", cacheKeyFull, err))
common.SysError(common.LogText("channel affinity cache get failed: key=%s, err=%v", cacheKeyFull, err))
return 0, false
}
if found {
@@ -672,7 +671,7 @@ func ClearCurrentChannelAffinityCache(c *gin.Context) bool {
cache := getChannelAffinityCache()
deleted, err := cache.DeleteMany([]string{cacheKey})
if err != nil {
common.SysError(fmt.Sprintf("channel affinity cache delete current failed: err=%v", err))
common.SysError(common.LogText("channel affinity cache delete current failed: err=%v", err))
return false
}
c.Set(ginKeyChannelAffinitySkipRetry, false)
@@ -764,7 +763,7 @@ func RecordChannelAffinity(c *gin.Context, channelID int) {
}
cache := getChannelAffinityCache()
if err := cache.SetWithTTL(cacheKey, channelID, time.Duration(ttlSeconds)*time.Second); err != nil {
common.SysError(fmt.Sprintf("channel affinity cache set failed: key=%s, err=%v", cacheKey, err))
common.SysError(common.LogText("channel affinity cache set failed: key=%s, err=%v", cacheKey, err))
}
}