feat: add affinity scheduling controls

This commit is contained in:
erio committed 2026-03-18 04:08:45 +08:00
1 parent 338e3df8d9
commit 44ec2626cf
44 files changed
+3711 -496

No files matched your search

+6 -1
View File
@@ -266,9 +266,14 @@ func AccountFromServiceShallow(a *service.Account) *Account {
}
// 客户端亲和调度(Anthropic 和 Antigravity 账号)
if a.IsClientAffinityEnabled() {
if a.IsAffinityEnabled() {
enabled := true
out.ClientAffinityEnabled = &enabled
allow := a.IsAffinityAllowSwitch()
out.AffinityAllowSwitch = &allow
if pinnedUsers := a.GetPinnedUsers(); len(pinnedUsers) > 0 {
out.PinnedUserIDs = pinnedUsers
}
}
// 提取账号配额限制(apikey / bedrock 类型有效)
+9
View File
@@ -201,6 +201,15 @@ type Account struct {
// 启用后新会话会优先调度到客户端之前使用过的账号
ClientAffinityEnabled *bool `json:"client_affinity_enabled,omitempty"`
// 亲和允许切换(默认 true)
AffinityAllowSwitch *bool `json:"affinity_allow_switch,omitempty"`
// 亲和用户数量(admin 列表端点注入)
AffinityUserCount *int64 `json:"affinity_user_count,omitempty"`
// 指定亲和用户 ID 列表
PinnedUserIDs []int64 `json:"pinned_user_ids,omitempty"`
// 亲和客户端数据(仅 admin 列表端点注入,不由 mapper 填充)
AffinityClientCount *int64 `json:"affinity_client_count,omitempty"`
AffinityClients []string `json:"affinity_clients,omitempty"`