Documentation
¶
Index ¶
- Constants
- func ApplyCustomHeadersFromMetadata(auth *Auth)
- func DefaultRuntimeSnapshotPath(configFilePath string) string
- func ExtractCustomHeadersFromMetadata(metadata map[string]any) map[string]string
- func ExtractSessionID(headers http.Header, payload []byte, metadata map[string]any) string
- func IsConfigAPIKeyAuth(auth *Auth) bool
- func IsRequestInterruptedError(err error) bool
- func OAuthModelAliasChannel(provider, authKind string) string
- func ProviderRefreshLead(provider string, runtime any) *time.Duration
- func RegisterRefreshLeadProvider(provider string, factory func() *time.Duration)
- func SaveRuntimeSnapshotToFile(path string, snapshot RuntimeSnapshot) error
- func SetQuotaCooldownDisabled(disable bool)
- func WithRequestInfo(ctx context.Context, info *RequestInfo) context.Context
- func WithSkipPersist(ctx context.Context) context.Context
- type APIKeyConfigEntry
- type Auth
- func (a *Auth) AccountInfo() (string, string)
- func (a *Auth) Clone() *Auth
- func (a *Auth) DisableCoolingOverride() (bool, bool)
- func (a *Auth) EnsureIndex() string
- func (a *Auth) ExpirationTime() (time.Time, bool)
- func (a *Auth) ProxyInfo() string
- func (a *Auth) RecentRequestsSnapshot(now time.Time) []RecentRequestBucket
- func (a *Auth) RequestRetryOverride() (int, bool)
- func (a *Auth) ToolPrefixDisabled() bool
- type AuthRuntimeState
- type Error
- type ExecutionSessionCloser
- type FillFirstSelector
- type Hook
- type Manager
- func (m *Manager) ApplyRuntimeSnapshot(snapshot RuntimeSnapshot, now time.Time) []string
- func (m *Manager) CloseExecutionSession(sessionID string)
- func (m *Manager) Execute(ctx context.Context, providers []string, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (m *Manager) ExecuteCount(ctx context.Context, providers []string, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (m *Manager) ExecuteStream(ctx context.Context, providers []string, req cliproxyexecutor.Request, ...) (*cliproxyexecutor.StreamResult, error)
- func (m *Manager) Executor(provider string) (ProviderExecutor, bool)
- func (m *Manager) ExportRuntimeSnapshot(now time.Time) RuntimeSnapshot
- func (m *Manager) GetByID(id string) (*Auth, bool)
- func (m *Manager) GetExecutionSessionAuthByID(sessionID string, authID string) (*Auth, bool)
- func (m *Manager) HomeEnabled() bool
- func (m *Manager) HttpRequest(ctx context.Context, auth *Auth, req *http.Request) (*http.Response, error)
- func (m *Manager) InjectCredentials(req *http.Request, authID string) error
- func (m *Manager) List() []*Auth
- func (m *Manager) Load(ctx context.Context) error
- func (m *Manager) MarkResult(ctx context.Context, result Result)
- func (m *Manager) NewHttpRequest(ctx context.Context, auth *Auth, method, targetURL string, body []byte, ...) (*http.Request, error)
- func (m *Manager) PrepareHttpRequest(ctx context.Context, auth *Auth, req *http.Request) error
- func (m *Manager) ReconcileRegistryModelStates(ctx context.Context, authID string)
- func (m *Manager) RefreshSchedulerEntry(authID string)
- func (m *Manager) Register(ctx context.Context, auth *Auth) (*Auth, error)
- func (m *Manager) RegisterExecutor(executor ProviderExecutor)
- func (m *Manager) SetConfig(cfg *internalconfig.Config)
- func (m *Manager) SetOAuthModelAlias(aliases map[string][]internalconfig.OAuthModelAlias)
- func (m *Manager) SetPluginScheduler(scheduler PluginScheduler)
- func (m *Manager) SetRetryConfig(retry int, maxRetryInterval time.Duration, maxRetryCredentials int)
- func (m *Manager) SetRoundTripperProvider(p RoundTripperProvider)
- func (m *Manager) SetSelector(selector Selector)
- func (m *Manager) SetStore(store Store)
- func (m *Manager) StartAutoRefresh(parent context.Context, interval time.Duration)
- func (m *Manager) StopAutoRefresh()
- func (m *Manager) UnregisterExecutor(provider string)
- func (m *Manager) Update(ctx context.Context, auth *Auth) (*Auth, error)
- type ModelState
- type NoopHook
- type PluginScheduler
- type PostAuthHook
- type ProviderExecutor
- type QuotaState
- type RecentRequestBucket
- type RefreshEvaluator
- type RequestAuthPreparer
- type RequestInfo
- type RequestPreparer
- type Result
- type RoundRobinSelector
- type RoundTripperProvider
- type RuntimeSnapshot
- type Selector
- type Status
- type StickyRoundRobinSelector
- type Store
Constants ¶
const ( // CloseAllExecutionSessionsID asks an executor to release all active execution sessions. // Executors that do not support this marker may ignore it. CloseAllExecutionSessionsID = "__all_execution_sessions__" )
Variables ¶
This section is empty.
Functions ¶
func ApplyCustomHeadersFromMetadata ¶
func ApplyCustomHeadersFromMetadata(auth *Auth)
func ExtractSessionID ¶
ExtractSessionID extracts a stable session identifier from request metadata, headers, or body.
func IsConfigAPIKeyAuth ¶
IsConfigAPIKeyAuth reports whether the auth entry is synthesized from config *-api-key lists.
func IsRequestInterruptedError ¶
IsRequestInterruptedError reports whether err represents a user/request cancellation rather than provider health.
func OAuthModelAliasChannel ¶
OAuthModelAliasChannel returns the OAuth model alias channel name for a given provider and auth kind. Returns empty string if the provider/authKind combination doesn't support OAuth model alias (e.g., API key authentication).
Supported channels: gemini-cli, vertex, aistudio, antigravity, claude, codex, kimi.
func SaveRuntimeSnapshotToFile ¶
func SaveRuntimeSnapshotToFile(path string, snapshot RuntimeSnapshot) error
func SetQuotaCooldownDisabled ¶
func SetQuotaCooldownDisabled(disable bool)
SetQuotaCooldownDisabled toggles quota cooldown scheduling globally.
func WithRequestInfo ¶
func WithRequestInfo(ctx context.Context, info *RequestInfo) context.Context
WithRequestInfo returns a new context with the given RequestInfo attached.
func WithSkipPersist ¶
WithSkipPersist returns a derived context that disables persistence for Manager Update/Register calls. It is intended for code paths that are reacting to file watcher events, where the file on disk is already the source of truth and persisting again would create a write-back loop.
Types ¶
type APIKeyConfigEntry ¶
APIKeyConfigEntry is a generic interface for API key configurations.
type Auth ¶
type Auth struct {
// ID uniquely identifies the auth record across restarts.
ID string `json:"id"`
// Index is a stable runtime identifier derived from auth metadata (not persisted).
Index string `json:"-"`
// Provider is the upstream provider key (e.g. "gemini", "claude").
Provider string `json:"provider"`
// Prefix optionally namespaces models for routing (e.g., "teamA/gemini-3-pro-preview").
Prefix string `json:"prefix,omitempty"`
// FileName stores the relative or absolute path of the backing auth file.
FileName string `json:"-"`
// Storage holds the token persistence implementation used during login flows.
Storage baseauth.TokenStorage `json:"-"`
// Label is an optional human readable label for logging.
Label string `json:"label,omitempty"`
// Status is the lifecycle status managed by the AuthManager.
Status Status `json:"status"`
// StatusMessage holds a short description for the current status.
StatusMessage string `json:"status_message,omitempty"`
// Disabled indicates the auth is intentionally disabled by operator.
Disabled bool `json:"disabled"`
Unavailable bool `json:"unavailable"`
// ProxyURL overrides the global proxy setting for this auth if provided.
ProxyURL string `json:"proxy_url,omitempty"`
// Attributes stores provider specific metadata needed by executors (immutable configuration).
Attributes map[string]string `json:"attributes,omitempty"`
// Metadata stores runtime mutable provider state (e.g. tokens, cookies).
Metadata map[string]any `json:"metadata,omitempty"`
// Quota captures recent quota information for load balancers.
Quota QuotaState `json:"quota"`
// LastError stores the last failure encountered while executing or refreshing.
LastError *Error `json:"last_error,omitempty"`
// CreatedAt is the creation timestamp in UTC.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the last modification timestamp in UTC.
UpdatedAt time.Time `json:"updated_at"`
// LastRefreshedAt records the last successful refresh time in UTC.
LastRefreshedAt time.Time `json:"last_refreshed_at"`
// NextRefreshAfter is the earliest time a refresh should retrigger.
NextRefreshAfter time.Time `json:"next_refresh_after"`
// NextRetryAfter is the earliest time a retry should retrigger.
NextRetryAfter time.Time `json:"next_retry_after"`
// ModelStates tracks per-model runtime availability data.
ModelStates map[string]*ModelState `json:"model_states,omitempty"`
// Runtime carries non-serialisable data used during execution (in-memory only).
Runtime any `json:"-"`
// Success / Failed are lifetime success/failure counters used by the plugin
// host when surfacing credential health to plugins. They are maintained
// opportunistically and are not persisted to disk.
Success int64 `json:"-"`
Failed int64 `json:"-"`
// contains filtered or unexported fields
}
Auth encapsulates the runtime state and metadata associated with a single credential.
func (*Auth) AccountInfo ¶
func (*Auth) Clone ¶
Clone shallow copies the Auth structure, duplicating maps to avoid accidental mutation.
func (*Auth) DisableCoolingOverride ¶
DisableCoolingOverride returns the auth-file scoped disable_cooling override when present. The value is read from metadata key "disable_cooling" (or legacy "disable-cooling").
func (*Auth) EnsureIndex ¶
EnsureIndex returns a stable index derived from the auth file name or credential identity.
func (*Auth) ExpirationTime ¶
ExpirationTime attempts to extract the credential expiration timestamp from metadata. It inspects common keys such as "expired", "expire", "expires_at", and also nested "token" objects to remain compatible with legacy auth file formats.
func (*Auth) RecentRequestsSnapshot ¶
func (a *Auth) RecentRequestsSnapshot(now time.Time) []RecentRequestBucket
RecentRequestsSnapshot returns the most recent bucket window ending at now. Buckets that have no recorded activity for their interval are returned with zero counters so callers always receive a fixed-length series.
func (*Auth) RequestRetryOverride ¶
RequestRetryOverride returns the auth-file scoped request_retry override when present. The value is read from metadata key "request_retry" (or legacy "request-retry").
func (*Auth) ToolPrefixDisabled ¶
ToolPrefixDisabled returns whether the proxy_ tool name prefix should be skipped for this auth. When true, tool names are sent to Anthropic unchanged. The value is read from metadata key "tool_prefix_disabled" (or "tool-prefix-disabled").
type AuthRuntimeState ¶
type AuthRuntimeState struct {
Status Status `json:"status"`
StatusMessage string `json:"status_message,omitempty"`
Quota QuotaState `json:"quota"`
LastError *Error `json:"last_error,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
NextRetryAfter time.Time `json:"next_retry_after"`
ModelStates map[string]*ModelState `json:"model_states,omitempty"`
}
func (*AuthRuntimeState) Clone ¶
func (r *AuthRuntimeState) Clone() *AuthRuntimeState
type Error ¶
type Error struct {
// Code is a short machine readable identifier.
Code string `json:"code,omitempty"`
// Message is a human readable description of the failure.
Message string `json:"message"`
// Retryable indicates whether a retry might fix the issue automatically.
Retryable bool `json:"retryable"`
// HTTPStatus optionally records an HTTP-like status code for the error.
HTTPStatus int `json:"http_status,omitempty"`
}
Error describes an authentication related failure in a provider agnostic format.
func (*Error) StatusCode ¶
StatusCode implements optional status accessor for manager decision making.
type ExecutionSessionCloser ¶
type ExecutionSessionCloser interface {
CloseExecutionSession(sessionID string)
}
ExecutionSessionCloser allows executors to release per-session runtime resources.
type FillFirstSelector ¶
type FillFirstSelector struct{}
FillFirstSelector selects the first available credential (deterministic ordering). This "burns" one account before moving to the next, which can help stagger rolling-window subscription caps (e.g. chat message limits).
type Hook ¶
type Hook interface {
// OnAuthRegistered fires when a new auth is registered.
OnAuthRegistered(ctx context.Context, auth *Auth)
// OnAuthUpdated fires when an existing auth changes state.
OnAuthUpdated(ctx context.Context, auth *Auth)
// OnResult fires when execution result is recorded.
OnResult(ctx context.Context, result Result)
}
Hook captures lifecycle callbacks for observing auth changes.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager orchestrates auth lifecycle, selection, execution, and persistence.
func NewManager ¶
NewManager constructs a manager with optional custom selector and hook.
func (*Manager) ApplyRuntimeSnapshot ¶
func (m *Manager) ApplyRuntimeSnapshot(snapshot RuntimeSnapshot, now time.Time) []string
func (*Manager) CloseExecutionSession ¶
CloseExecutionSession asks all registered executors to release the supplied execution session.
func (*Manager) Execute ¶
func (m *Manager) Execute(ctx context.Context, providers []string, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
Execute performs a non-streaming execution using the configured selector and executor. It supports multiple providers for the same model and round-robins the starting provider per model.
func (*Manager) ExecuteCount ¶
func (m *Manager) ExecuteCount(ctx context.Context, providers []string, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
ExecuteCount performs a non-streaming execution using the configured selector and executor. It supports multiple providers for the same model and round-robins the starting provider per model.
func (*Manager) ExecuteStream ¶
func (m *Manager) ExecuteStream(ctx context.Context, providers []string, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (*cliproxyexecutor.StreamResult, error)
ExecuteStream performs a streaming execution using the configured selector and executor. It supports multiple providers for the same model and round-robins the starting provider per model.
func (*Manager) Executor ¶
func (m *Manager) Executor(provider string) (ProviderExecutor, bool)
Executor returns the registered provider executor for a provider key.
func (*Manager) ExportRuntimeSnapshot ¶
func (m *Manager) ExportRuntimeSnapshot(now time.Time) RuntimeSnapshot
func (*Manager) GetExecutionSessionAuthByID ¶
GetExecutionSessionAuthByID retrieves a Home runtime auth scoped to an execution session.
func (*Manager) HomeEnabled ¶
HomeEnabled reports whether the Home control plane integration is enabled in the runtime config.
func (*Manager) HttpRequest ¶
func (m *Manager) HttpRequest(ctx context.Context, auth *Auth, req *http.Request) (*http.Response, error)
HttpRequest injects provider credentials into the supplied HTTP request and executes it.
func (*Manager) InjectCredentials ¶
InjectCredentials delegates per-provider HTTP request preparation when supported. If the registered executor for the auth provider implements RequestPreparer, it will be invoked to modify the request (e.g., add headers).
func (*Manager) MarkResult ¶
MarkResult records an execution result and notifies hooks.
func (*Manager) NewHttpRequest ¶
func (m *Manager) NewHttpRequest(ctx context.Context, auth *Auth, method, targetURL string, body []byte, headers http.Header) (*http.Request, error)
NewHttpRequest constructs a new HTTP request and injects provider credentials into it.
func (*Manager) PrepareHttpRequest ¶
PrepareHttpRequest injects provider credentials into the supplied HTTP request.
func (*Manager) ReconcileRegistryModelStates ¶
ReconcileRegistryModelStates aligns per-model runtime state with the current registry snapshot for one auth.
Supported models are reset to a clean state because re-registration already cleared the registry-side cooldown/suspension snapshot. ModelStates for models that are no longer present in the registry are pruned entirely so renamed/removed models cannot keep auth-level status stale.
func (*Manager) RefreshSchedulerEntry ¶
RefreshSchedulerEntry re-upserts a single auth into the scheduler so that its supportedModelSet is rebuilt from the current global model registry state. This must be called after models have been registered for a newly added auth, because the initial scheduler.upsertAuth during Register/Update runs before registerModelsForAuth and therefore snapshots an empty model set.
func (*Manager) RegisterExecutor ¶
func (m *Manager) RegisterExecutor(executor ProviderExecutor)
RegisterExecutor registers a provider executor with the manager.
func (*Manager) SetConfig ¶
func (m *Manager) SetConfig(cfg *internalconfig.Config)
SetConfig updates the runtime config snapshot used by request-time helpers. Callers should provide the latest config on reload so per-credential alias mapping stays in sync.
func (*Manager) SetOAuthModelAlias ¶
func (m *Manager) SetOAuthModelAlias(aliases map[string][]internalconfig.OAuthModelAlias)
SetOAuthModelAlias updates the OAuth model name alias table used during execution. The alias is applied per-auth channel to resolve the upstream model name while keeping the client-visible model name unchanged for translation/response formatting.
func (*Manager) SetPluginScheduler ¶
func (m *Manager) SetPluginScheduler(scheduler PluginScheduler)
SetPluginScheduler installs the dynamic plugin scheduler used for plugin-owned providers.
func (*Manager) SetRetryConfig ¶
func (m *Manager) SetRetryConfig(retry int, maxRetryInterval time.Duration, maxRetryCredentials int)
SetRetryConfig updates retry attempts, credential retry limit and cooldown wait interval.
func (*Manager) SetRoundTripperProvider ¶
func (m *Manager) SetRoundTripperProvider(p RoundTripperProvider)
SetRoundTripperProvider register a provider that returns a per-auth RoundTripper.
func (*Manager) SetSelector ¶
func (*Manager) StartAutoRefresh ¶
StartAutoRefresh launches a background loop that evaluates auth freshness every few seconds and triggers refresh operations when required. Only one loop is kept alive; starting a new one cancels the previous run.
func (*Manager) StopAutoRefresh ¶
func (m *Manager) StopAutoRefresh()
StopAutoRefresh cancels the background refresh loop, if running.
func (*Manager) UnregisterExecutor ¶
UnregisterExecutor removes the executor associated with the provider key.
type ModelState ¶
type ModelState struct {
// Status reflects the lifecycle status for this model.
Status Status `json:"status"`
// StatusMessage provides an optional short description of the status.
StatusMessage string `json:"status_message,omitempty"`
Unavailable bool `json:"unavailable"`
// NextRetryAfter defines the per-model retry time.
NextRetryAfter time.Time `json:"next_retry_after"`
// LastError records the latest error observed for this model.
LastError *Error `json:"last_error,omitempty"`
// Quota retains quota information if this model hit rate limits.
Quota QuotaState `json:"quota"`
// UpdatedAt tracks the last update timestamp for this model state.
UpdatedAt time.Time `json:"updated_at"`
}
ModelState captures the execution state for a specific model under an auth entry.
func (*ModelState) Clone ¶
func (m *ModelState) Clone() *ModelState
Clone duplicates a model state including nested error details.
type NoopHook ¶
type NoopHook struct{}
NoopHook provides optional hook defaults.
func (NoopHook) OnAuthRegistered ¶
OnAuthRegistered implements Hook.
func (NoopHook) OnAuthUpdated ¶
OnAuthUpdated implements Hook.
type PluginScheduler ¶
type PluginScheduler interface {
PickAuth(context.Context, pluginapi.SchedulerPickRequest) (pluginapi.SchedulerPickResponse, bool, error)
}
PluginScheduler lets dynamic plugins override auth selection for their providers.
type PostAuthHook ¶
PostAuthHook defines a function that is called after an Auth record is created but before it is persisted to storage. This allows for modification of the Auth record (e.g., injecting metadata) based on external context.
type ProviderExecutor ¶
type ProviderExecutor interface {
// Identifier returns the provider key handled by this executor.
Identifier() string
// Execute handles non-streaming execution and returns the provider response payload.
Execute(ctx context.Context, auth *Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
// ExecuteStream handles streaming execution and returns a StreamResult containing
// upstream headers and a channel of provider chunks.
ExecuteStream(ctx context.Context, auth *Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (*cliproxyexecutor.StreamResult, error)
// Refresh attempts to refresh provider credentials and returns the updated auth state.
Refresh(ctx context.Context, auth *Auth) (*Auth, error)
// CountTokens returns the token count for the given request.
CountTokens(ctx context.Context, auth *Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
// HttpRequest injects provider credentials into the supplied HTTP request and executes it.
// Callers must close the response body when non-nil.
HttpRequest(ctx context.Context, auth *Auth, req *http.Request) (*http.Response, error)
}
ProviderExecutor defines the contract required by Manager to execute provider calls.
type QuotaState ¶
type QuotaState struct {
// Exceeded indicates the credential recently hit a quota error.
Exceeded bool `json:"exceeded"`
// Reason provides an optional provider specific human readable description.
Reason string `json:"reason,omitempty"`
// NextRecoverAt is when the credential may become available again.
NextRecoverAt time.Time `json:"next_recover_at"`
// BackoffLevel stores the progressive cooldown exponent used for rate limits.
BackoffLevel int `json:"backoff_level,omitempty"`
}
QuotaState contains limiter tracking data for a credential.
type RecentRequestBucket ¶
type RecentRequestBucket struct {
Time string `json:"time"`
Success int64 `json:"success"`
Failed int64 `json:"failed"`
}
RecentRequestBucket is the exported snapshot entry returned by RecentRequestsSnapshot. Time is a human-readable local-clock label so the value can be displayed directly in management UIs.
type RefreshEvaluator ¶
RefreshEvaluator allows runtime state to override refresh decisions.
type RequestAuthPreparer ¶
type RequestAuthPreparer interface {
ShouldPrepareRequestAuth(auth *Auth) bool
PrepareRequestAuth(ctx context.Context, auth *Auth) (*Auth, error)
}
RequestAuthPreparer lets an executor update missing auth metadata immediately before a request.
type RequestInfo ¶
RequestInfo holds information extracted from the HTTP request. It is injected into the context passed to PostAuthHook.
func GetRequestInfo ¶
func GetRequestInfo(ctx context.Context) *RequestInfo
GetRequestInfo retrieves the RequestInfo from the context, if present.
type RequestPreparer ¶
RequestPreparer is an optional interface that provider executors can implement to mutate outbound HTTP requests with provider credentials.
type Result ¶
type Result struct {
// AuthID references the auth that produced this result.
AuthID string
// Provider is copied for convenience when emitting hooks.
Provider string
// Model is the upstream model identifier used for the request.
Model string
// Success marks whether the execution succeeded.
Success bool
// RetryAfter carries a provider supplied retry hint (e.g. 429 retryDelay).
RetryAfter *time.Duration
// Error describes the failure when Success is false.
Error *Error
}
Result captures execution outcome used to adjust auth state.
type RoundRobinSelector ¶
type RoundRobinSelector struct {
// contains filtered or unexported fields
}
RoundRobinSelector provides a simple provider scoped round-robin selection strategy.
func (*RoundRobinSelector) Pick ¶
func (s *RoundRobinSelector) Pick(ctx context.Context, provider, model string, opts cliproxyexecutor.Options, auths []*Auth) (*Auth, error)
Pick selects the next available auth for the provider in a round-robin manner. For gemini-cli virtual auths (identified by the gemini_virtual_parent attribute), a two-level round-robin is used: first cycling across credential groups (parent accounts), then cycling within each group's project auths.
type RoundTripperProvider ¶
type RoundTripperProvider interface {
RoundTripperFor(auth *Auth) http.RoundTripper
}
RoundTripperProvider defines a minimal provider of per-auth HTTP transports.
type RuntimeSnapshot ¶
type RuntimeSnapshot struct {
Auths map[string]*AuthRuntimeState `json:"auths,omitempty"`
}
func LoadRuntimeSnapshotFromFile ¶
func LoadRuntimeSnapshotFromFile(path string) (RuntimeSnapshot, error)
func (RuntimeSnapshot) Clone ¶
func (s RuntimeSnapshot) Clone() RuntimeSnapshot
func (RuntimeSnapshot) Len ¶
func (s RuntimeSnapshot) Len() int
type Selector ¶
type Selector interface {
Pick(ctx context.Context, provider, model string, opts cliproxyexecutor.Options, auths []*Auth) (*Auth, error)
}
Selector chooses an auth candidate for execution.
type Status ¶
type Status string
Status represents the lifecycle state of an Auth entry.
const ( // StatusUnknown means the auth state could not be determined. StatusUnknown Status = "unknown" // StatusActive indicates the auth is valid and ready for execution. StatusActive Status = "active" // StatusPending indicates the auth is waiting for an external action, such as MFA. StatusPending Status = "pending" // StatusRefreshing indicates the auth is undergoing a refresh flow. StatusRefreshing Status = "refreshing" // StatusError indicates the auth is temporarily unavailable due to errors. StatusError Status = "error" // StatusDisabled marks the auth as intentionally disabled. StatusDisabled Status = "disabled" )
type StickyRoundRobinSelector ¶
type StickyRoundRobinSelector struct{ RoundRobinSelector }
StickyRoundRobinSelector enables scheduler-managed sticky affinity with round-robin fallback. The concrete sticky binding behavior is implemented by the built-in auth scheduler. The embedded round-robin selector keeps this type compatible with the Selector interface.
type Store ¶
type Store interface {
// List returns all auth records stored in the backend.
List(ctx context.Context) ([]*Auth, error)
// Save persists the provided auth record, replacing any existing one with same ID.
Save(ctx context.Context, auth *Auth) (string, error)
// Delete removes the auth record identified by id.
Delete(ctx context.Context, id string) error
}
Store abstracts persistence of Auth state across restarts.