Documentation
¶
Index ¶
- Constants
- Variables
- func CheckedInLocalDay(at, status string, now time.Time) bool
- func NormalizeWeight(priority int) int
- func NormalizeWorkBuddyCheckinTime(value string) (string, error)
- func PersistRetryBackoff() time.Duration
- func QoderRuntimeSpec(cfg ManagerConfig, account Account, home string) (cliPath, site, configDir, configEnv string, err error)
- func StarterEnv(config ManagerConfig, account Account, home string, port int) ([]string, error)
- type APIKeyConfigurableStarter
- type Account
- type AccountStore
- type AccountView
- type CheckinRecord
- type Classified
- type CooldownRow
- type CreateAccount
- type DetachedRefreshError
- type ExecStarter
- type ImportAccount
- type Item
- type ManagedProcess
- type Manager
- func (m *Manager) AccountURL(id string) (string, bool)
- func (m *Manager) AccountView(ctx context.Context, id string) (AccountView, error)
- func (m *Manager) Accounts(ctx context.Context) ([]AccountView, error)
- func (manager *Manager) CheckinAccount(ctx context.Context, accountID string) (Account, error)
- func (manager *Manager) CheckinAll(ctx context.Context, force, includeDisabled bool) ([]accounts.CheckinAllResult, error)
- func (manager *Manager) CheckinOptedIn(ctx context.Context)
- func (m *Manager) Close() error
- func (m *Manager) Create(ctx context.Context, input CreateAccount) (Account, error)
- func (m *Manager) Delete(ctx context.Context, id string) error
- func (m *Manager) EnsureModelCatalogs(ctx context.Context, force bool)
- func (m *Manager) Flush()
- func (m *Manager) Import(ctx context.Context, input ImportAccount) (Account, error)
- func (manager *Manager) KeepaliveWorkBuddy(ctx context.Context, onlyOptIn bool, done map[string]struct{}) (more bool)
- func (m *Manager) Pool() *Pool
- func (m *Manager) ProxyAPIKey() string
- func (m *Manager) RefreshAccount(ctx context.Context, id string, forceQuota bool) error
- func (m *Manager) RefreshAll(ctx context.Context, forceQuota bool) error
- func (m *Manager) RefreshFEFOQuotaAfterUse(accountID, publicModel string)
- func (m *Manager) ReloadProxyURL(ctx context.Context, value string) error
- func (m *Manager) RemoveAccount(id string) error
- func (m *Manager) ReplaceProxyAPIKey(ctx context.Context, key string) error
- func (m *Manager) Resources() ResourceSnapshot
- func (manager *Manager) RunMaintenanceLoop(stop <-chan struct{})
- func (m *Manager) SetProviders(registry *providers.Registry)
- func (m *Manager) SetWorkBuddy(ops WorkBuddyMaintainer)
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) StartAccount(ctx context.Context, account Account) error
- func (m *Manager) StopAccount(id string) error
- func (m *Manager) Store() AccountStore
- func (m *Manager) SyncAccount(ctx context.Context, before, after Account) error
- func (m *Manager) SyncCredential(ctx context.Context, id, authType string) error
- func (m *Manager) TestCheckinOptedIn(ctx context.Context, now time.Time, scheduledTime string, retryDue bool)
- func (m *Manager) TestPersistDirtyLen() int
- func (m *Manager) TestPersistSnapshot(id string) (item Item, version uint64, ok bool)
- func (m *Manager) TestProcess(id string) ManagedProcess
- func (m *Manager) TestProcessCount() int
- func (m *Manager) TestRecoverPending(id string) bool
- func (m *Manager) TestRecovering(id string) bool
- func (m *Manager) TestRestartDelay(level int) time.Duration
- func (m *Manager) TestRestoreCooldowns(ctx context.Context)
- func (m *Manager) TestSetRecoverUnwindHook(hook func(id string))
- func (m *Manager) TestStartAccount(ctx context.Context, account Account) error
- func (m *Manager) Update(ctx context.Context, id string, input UpdateAccount) error
- func (m *Manager) WorkerAdmin(ctx context.Context, input providers.AdminRequest) (providers.AdminResponse, error)
- func (m *Manager) WorkerPIDs() map[string]int
- type ManagerConfig
- type NativeCredential
- type Pool
- type PoolStateStore
- type ProcessResources
- type ProcessStarter
- type ProxyConfigurableStarter
- type QuotaRefreshError
- type QuotaSnapshot
- type ResourceSnapshot
- type UpdateAccount
- type WorkBuddyMaintainer
- type WorkerResources
Constants ¶
const ( KindAuth = accounts.KindAuth DefaultWorkBuddyCheckinTime = accounts.DefaultWorkBuddyCheckinTime )
Variables ¶
var ErrAccountNotFound = accounts.ErrAccountNotFound
Functions ¶
func NormalizeWeight ¶
func PersistRetryBackoff ¶
func QoderRuntimeSpec ¶
func QoderRuntimeSpec(cfg ManagerConfig, account Account, home string) (cliPath, site, configDir, configEnv string, err error)
func StarterEnv ¶
Types ¶
type APIKeyConfigurableStarter ¶
type APIKeyConfigurableStarter interface {
SetProxyAPIKey(string)
}
APIKeyConfigurableStarter is the sibling of ProxyConfigurableStarter for the manager's proxy API key.
type AccountStore ¶
type AccountStore = accounts.AccountStore
type AccountView ¶
type AccountView = accounts.AccountView
type CheckinRecord ¶
type CheckinRecord = accounts.CheckinRecord
type Classified ¶
type Classified = executor.Classified
type CooldownRow ¶
type CooldownRow = accounts.CooldownRow
type CreateAccount ¶
type CreateAccount = accounts.CreateAccount
type DetachedRefreshError ¶ added in v0.7.35
type DetachedRefreshError struct{ Provider string }
DetachedRefreshError reports that a disabled account cannot be refreshed. It is returned when the provider has no in-process prober at all, or when the probe reports not-ready without an error (for example a legacy Qoder worker account that predates the PAT model and has no live worker). Such an account must be enabled first so a worker can be spawned before its status/quota can be read.
func (*DetachedRefreshError) Error ¶ added in v0.7.35
func (e *DetachedRefreshError) Error() string
type ExecStarter ¶
type ExecStarter struct {
// Config is initial configuration; after first use access it through methods.
Config ManagerConfig
// contains filtered or unexported fields
}
func NewExecStarter ¶
func NewExecStarter(config ManagerConfig) *ExecStarter
func (*ExecStarter) ConfigSnapshot ¶
func (s *ExecStarter) ConfigSnapshot() ManagerConfig
func (*ExecStarter) SetProxyAPIKey ¶
func (s *ExecStarter) SetProxyAPIKey(value string)
func (*ExecStarter) SetProxyURL ¶
func (s *ExecStarter) SetProxyURL(value string)
func (*ExecStarter) Start ¶
func (s *ExecStarter) Start(ctx context.Context, account Account, home string, port int) (ManagedProcess, error)
type ImportAccount ¶
type ImportAccount = accounts.ImportAccount
type ManagedProcess ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(config ManagerConfig, store AccountStore, starter ProcessStarter) *Manager
func (*Manager) AccountView ¶
RefreshAccount re-probes one account's health, quota, and model catalog. forceQuota bypasses the worker's own quota cache, matching the console's "Refresh credits" button. It refreshes only the requested account, so a
func (*Manager) CheckinAccount ¶
func (*Manager) CheckinAll ¶ added in v0.7.40
func (manager *Manager) CheckinAll(ctx context.Context, force, includeDisabled bool) ([]accounts.CheckinAllResult, error)
CheckinAll runs a manual all-account pass on the server. It selects from the full store instead of the browser's current page/filter, honors the system "check in disabled accounts" setting, and reports every account outcome.
func (*Manager) CheckinOptedIn ¶
func (*Manager) EnsureModelCatalogs ¶
EnsureModelCatalogs refreshes per-account catalogs that are missing or older than the worker TTL. Failures leave the previous snapshot in place and never flip readiness or cooldown.
Refreshes run concurrently in the background with a bounded semaphore so the first chat request is never blocked by N serial 15-second timeouts when multiple accounts are offline. The caller returns immediately; a nil Models slice means unknown (fail open) until the background refresh completes and subsequent requests use the fresh catalog.
func (*Manager) Flush ¶
func (m *Manager) Flush()
Flush waits for all cooldown writes queued so far to be persisted. The marker fires only once the dirty set has drained to empty, so every account's newest state enqueued before this call is persisted before Flush returns.
func (*Manager) KeepaliveWorkBuddy ¶
func (manager *Manager) KeepaliveWorkBuddy(ctx context.Context, onlyOptIn bool, done map[string]struct{}) (more bool)
KeepaliveWorkBuddy refreshes WorkBuddy sessions. At most maintenancePerTickCap accounts are processed per call, with maintenanceAccountGap between them. done tracks account IDs already refreshed for the current local day; pass the same map across successive maintenance ticks. Returns true when more eligible accounts remain.
func (*Manager) ProxyAPIKey ¶
func (*Manager) RefreshAccount ¶
func (*Manager) RefreshAll ¶
AccountView returns the same projection the accounts list builds, for one
func (*Manager) RefreshFEFOQuotaAfterUse ¶ added in v0.7.13
RefreshFEFOQuotaAfterUse invalidates a trusted credit balance after the whole response (including an SSE body) finishes. It never waits on upstream quota in the request path. Concurrent completions share one fetch; a completion during that fetch requests one trailing fetch so its consumption is not lost.
func (*Manager) ReloadProxyURL ¶
func (*Manager) RemoveAccount ¶
func (*Manager) ReplaceProxyAPIKey ¶
func (*Manager) Resources ¶ added in v0.6.14
func (m *Manager) Resources() ResourceSnapshot
Resources returns the most recent resource snapshot. The maintenance loop refreshes it on every tick; if it has never run (tests, minimal embedding) a sample is taken synchronously.
func (*Manager) RunMaintenanceLoop ¶ added in v0.6.1
func (manager *Manager) RunMaintenanceLoop(stop <-chan struct{})
func (*Manager) SetProviders ¶
SetProviders wires optional in-process account probers (WorkBuddy, etc.).
func (*Manager) SetWorkBuddy ¶
func (m *Manager) SetWorkBuddy(ops WorkBuddyMaintainer)
SetWorkBuddy wires Phase N check-in / keepalive without a second scheduler package.
func (*Manager) StartAccount ¶
func (*Manager) StopAccount ¶
func (*Manager) Store ¶
func (m *Manager) Store() AccountStore
func (*Manager) SyncAccount ¶
func (*Manager) SyncCredential ¶
func (*Manager) TestCheckinOptedIn ¶
func (*Manager) TestPersistDirtyLen ¶
func (*Manager) TestPersistSnapshot ¶
func (*Manager) TestProcess ¶
func (m *Manager) TestProcess(id string) ManagedProcess
func (*Manager) TestProcessCount ¶
func (*Manager) TestRecoverPending ¶ added in v0.7.1
TestRecoverPending reports whether a failure is queued behind an active recovery.
func (*Manager) TestRecovering ¶
func (*Manager) TestRestoreCooldowns ¶
func (*Manager) TestSetRecoverUnwindHook ¶ added in v0.7.1
TestSetRecoverUnwindHook installs a hook run when a recovery goroutine starts unwinding, before it clears the recovering guard. Tests only.
func (*Manager) TestStartAccount ¶
func (*Manager) WorkerAdmin ¶
func (m *Manager) WorkerAdmin(ctx context.Context, input providers.AdminRequest) (providers.AdminResponse, error)
WorkerAdmin coordinates worker readiness and authoritative credential sync. HTTP status/body are opaque worker protocol results, not public handlers.
func (*Manager) WorkerPIDs ¶ added in v0.6.14
WorkerPIDs maps account ID -> OS PID for managed child processes. In-process providers never appear here. Safe for concurrent use.
type ManagerConfig ¶
type NativeCredential ¶
type NativeCredential = accounts.NativeCredential
type PoolStateStore ¶
type PoolStateStore = accounts.PoolStateStore
type ProcessResources ¶ added in v0.6.14
type ProcessStarter ¶
type ProxyConfigurableStarter ¶
type ProxyConfigurableStarter interface {
SetProxyURL(string)
}
ProxyConfigurableStarter lets the manager push the global outbound proxy to a starter that can apply it to newly spawned workers. Kept optional so test starters need not implement it.
type QuotaRefreshError ¶ added in v0.6.20
type QuotaRefreshError struct{ Err error }
QuotaRefreshError reports an upstream quota refresh failure without implying that the account itself is unhealthy or unavailable.
func (*QuotaRefreshError) Error ¶ added in v0.6.20
func (e *QuotaRefreshError) Error() string
func (*QuotaRefreshError) Unwrap ¶ added in v0.6.20
func (e *QuotaRefreshError) Unwrap() error
type QuotaSnapshot ¶
type QuotaSnapshot = accounts.QuotaSnapshot
type ResourceSnapshot ¶ added in v0.6.14
type ResourceSnapshot struct {
SampledAt time.Time `json:"sampled_at"`
Server ProcessResources `json:"server"`
Workers []WorkerResources `json:"workers"`
}
ResourceSnapshot is a point-in-time view of host process usage for the server and each managed worker process. CPU percent follows the ps/top convention: 100 == one core fully busy.
type UpdateAccount ¶
type UpdateAccount = accounts.UpdateAccount
type WorkBuddyMaintainer ¶
type WorkBuddyMaintainer interface {
DailyCheckin(ctx context.Context, accountID string) (string, error)
Keepalive(ctx context.Context, accountID string) error
}
WorkBuddyMaintainer is the Phase N ops surface. Implemented by workbuddy.Client; kept narrow so accounts does not grow a generic check-in capability on AccountProber.