pool

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalPool = NewPoolManager()

Functions

This section is empty.

Types

type AccountPool

type AccountPool struct {
	// contains filtered or unexported fields
}

func (*AccountPool) ListUsage

func (p *AccountPool) ListUsage() []*AccountUsage

func (*AccountPool) RecordUsage

func (p *AccountPool) RecordUsage(accountID string, tokens int64)

func (*AccountPool) RegisterAccount

func (p *AccountPool) RegisterAccount(accountID string, weight float64)

func (*AccountPool) RegisterAccountWithInfo

func (p *AccountPool) RegisterAccountWithInfo(accountID, poolID, providerID string, weight float64)

func (*AccountPool) RemoveAccount

func (p *AccountPool) RemoveAccount(accID string)

func (*AccountPool) SelectBestAccount

func (p *AccountPool) SelectBestAccount(candidates []string) string

SelectBestAccount implements Fair-Share Token Balancing. It selects the account with the lowest normalized token usage (WindowTokens / Weight).

func (*AccountPool) SetAccountDisabled

func (p *AccountPool) SetAccountDisabled(accountID string, disabled bool)

func (*AccountPool) SetCooldown

func (p *AccountPool) SetCooldown(accountID string, duration time.Duration)

type AccountUsage

type AccountUsage struct {
	AccountID     string    `json:"account_id"`
	PoolID        string    `json:"pool_id"`
	ProviderID    string    `json:"provider_id"`
	TotalTokens   int64     `json:"total_tokens"`
	TotalRequests int64     `json:"total_requests"`
	WindowTokens  int64     `json:"window_tokens"` // Tokens consumed in current rolling window
	WindowStart   time.Time `json:"window_start"`
	Weight        float64   `json:"weight"` // Relative quota weighting, default 1.0
	Status        string    `json:"status"` // "active", "cooldown", "disabled"
	CooldownUntil time.Time `json:"cooldown_until"`
}

type PoolManager

type PoolManager struct {
	// contains filtered or unexported fields
}

func NewPoolManager

func NewPoolManager() *PoolManager

func (*PoolManager) GetOrCreatePool

func (m *PoolManager) GetOrCreatePool(poolID, mode string) *AccountPool

func (*PoolManager) ListAllPools

func (m *PoolManager) ListAllPools() map[string][]*AccountUsage

func (*PoolManager) RecordUsage

func (m *PoolManager) RecordUsage(poolID, accID string, tokens int64)

func (*PoolManager) RegisterAccount

func (m *PoolManager) RegisterAccount(poolID, provID, accID string, weight float64)

func (*PoolManager) RemoveAccount

func (m *PoolManager) RemoveAccount(poolID, accID string)

func (*PoolManager) SetAccountDisabled

func (m *PoolManager) SetAccountDisabled(accID string, disabled bool)

func (*PoolManager) SetCooldown

func (m *PoolManager) SetCooldown(poolID, accID string, duration time.Duration)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL