Documentation
¶
Index ¶
- type AccountPool
- func (p *AccountPool) Add(client *gemini.Client, accountID string)
- func (p *AccountPool) AddUnavailable(accountID string)
- func (p *AccountPool) BindSession(sessionKey string, accountID string)
- func (p *AccountPool) ClearSession(sessionKey string)
- func (p *AccountPool) Clients() []*gemini.Client
- func (p *AccountPool) HasModel(modelID string) bool
- func (p *AccountPool) HasReadyModel(modelID string) bool
- func (p *AccountPool) NextForModel(sessionKey string, modelID string) (*gemini.Client, string)
- func (p *AccountPool) NextForModelExcluding(sessionKey string, modelID string, excludedAccountIDs map[string]struct{}) (*gemini.Client, string)
- func (p *AccountPool) Recover(ctx context.Context, client *gemini.Client, accountID string, ...) bool
- func (p *AccountPool) ReportFailure(accountID string)
- func (p *AccountPool) ReportSuccess(accountID string)
- func (p *AccountPool) Size() int
- func (p *AccountPool) Status() PoolStatus
- func (p *AccountPool) Usage(ctx context.Context) PoolUsageStatus
- type AccountStatus
- type AccountUsageStatus
- type PoolStatus
- type PoolUsageStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountPool ¶
type AccountPool struct {
// contains filtered or unexported fields
}
AccountPool 在健康账号之间调度请求并维护显式会话粘性
func NewAccountPool ¶
func NewAccountPool(cooldown time.Duration, sessionTTL time.Duration) *AccountPool
NewAccountPool 创建账号池
func (*AccountPool) Add ¶
func (p *AccountPool) Add(client *gemini.Client, accountID string)
Add 添加一个已经完成协议初始化的账号
func (*AccountPool) AddUnavailable ¶
func (p *AccountPool) AddUnavailable(accountID string)
AddUnavailable 记录一个启动失败的账号
func (*AccountPool) BindSession ¶
func (p *AccountPool) BindSession(sessionKey string, accountID string)
BindSession 将成功响应标识绑定到产生它的账号
func (*AccountPool) ClearSession ¶
func (p *AccountPool) ClearSession(sessionKey string)
ClearSession 结束显式会话的账号粘性
func (*AccountPool) HasModel ¶
func (p *AccountPool) HasModel(modelID string) bool
HasModel 报告已初始化账号是否发现目标模型
func (*AccountPool) HasReadyModel ¶
func (p *AccountPool) HasReadyModel(modelID string) bool
HasReadyModel 报告当前是否有健康账号可以运行目标模型
func (*AccountPool) NextForModel ¶
NextForModel 为新请求选择真正支持目标模型的健康账号
func (*AccountPool) NextForModelExcluding ¶
func (p *AccountPool) NextForModelExcluding(sessionKey string, modelID string, excludedAccountIDs map[string]struct{}) (*gemini.Client, string)
NextForModelExcluding 为无会话重试选择未排除的同能力账号
func (*AccountPool) Recover ¶ added in v0.1.2
func (p *AccountPool) Recover(ctx context.Context, client *gemini.Client, accountID string, interval time.Duration, init func(context.Context) error) bool
Recover 按间隔调用 init 重新初始化启动失败的账号,成功后把客户端加入调度并返回 true,ctx 结束时返回 false
func (*AccountPool) ReportFailure ¶
func (p *AccountPool) ReportFailure(accountID string)
ReportFailure 将账号移入冷却
func (*AccountPool) ReportSuccess ¶
func (p *AccountPool) ReportSuccess(accountID string)
ReportSuccess 清除账号的连续失败状态
func (*AccountPool) Usage ¶
func (p *AccountPool) Usage(ctx context.Context) PoolUsageStatus
Usage 并发读取全部已初始化账号的官网用量
type AccountStatus ¶
type AccountStatus struct {
AccountID string `json:"account_id"`
State string `json:"state"`
LastUsed *time.Time `json:"last_used,omitempty"`
CooldownUntil *time.Time `json:"cooldown_until,omitempty"`
ConsecutiveFails int `json:"consecutive_failures"`
}
AccountStatus 是健康检查使用的脱敏账号状态
type AccountUsageStatus ¶
type AccountUsageStatus struct {
AccountID string `json:"account_id"`
State string `json:"state"`
Usage *gemini.UsageInfo `json:"usage,omitempty"`
Error string `json:"error,omitempty"`
}
AccountUsageStatus 表示单个账号的实时官网用量
type PoolStatus ¶
type PoolStatus struct {
Total int `json:"total"`
Available int `json:"available"`
CoolingDown int `json:"cooling_down"`
Accounts []AccountStatus `json:"accounts"`
}
PoolStatus 汇总账号池状态
type PoolUsageStatus ¶
type PoolUsageStatus struct {
Accounts []AccountUsageStatus `json:"accounts"`
}
PoolUsageStatus 汇总账号池实时官网用量