Documentation
¶
Index ¶
- Constants
- Variables
- func APIKeyHash(apiKey string) string
- func ApplyOriginalAuthFileName(auths []*coreauth.Auth, filename string)
- func AutoMigrate(db *gorm.DB) error
- func CanonicalPeriodWindowMode(mode string, allowCalendar bool) string
- func ClientAddr(ctx context.Context, db *gorm.DB) (string, error)
- func ConfigRootFromSnapshot(snapshot map[string]json.RawMessage) (map[string]any, error)
- func DatabaseNow(ctx context.Context, tx *gorm.DB) (time.Time, error)
- func DefaultHeartbeatTimeout() time.Duration
- func DeleteFingerprintConcurrencyCountersTx(ctx context.Context, tx *gorm.DB, fingerprint string) error
- func DeterministicAPIKeyUUID(provider, baseURL, apiKeyHash, compatName, providerKey string) string
- func EnsureOAuthPayloadUUID(raw []byte) ([]byte, string, bool, error)
- func ForwardRefreshToMaster(ctx context.Context, master *ClusterNodeRecord, authUUID string, secret string, ...) ([]byte, error)
- func HTTPClientTLSConfig(tlsConfig *tls.Config, serverName string) (*tls.Config, error)
- func HashUserSecurityValue(value string) string
- func IsAPIKeyConflictError(err error) bool
- func IsConcurrencySaturated(err error) bool
- func IsUserConflictError(err error) bool
- func IsUserEmailConflictError(err error) bool
- func ModelGroupDetailChannelIDs(record *ModelGroupDetailRecord) ([]uint, error)
- func NormalizeQuotaWindowValues(window *QuotaWindow)
- func OAuthSessionData(record *OAuthSessionRecord) (map[string]any, error)
- func Open(ctx context.Context, cfg PGSQLConfig) (*gorm.DB, error)
- func OpenSQLite(ctx context.Context, path string) (*gorm.DB, error)
- func ParseChannelRecordID(value string) (uint, error)
- func ParseModelRecordID(value string) (uint, error)
- func ParseUserRecordID(value string) (uint, error)
- func QuotaSnapshotVersion(provider string) int
- func RecordToAuth(record *AuthRecord) (*coreauth.Auth, error)
- func RuntimeConfigFromRoot(root map[string]any) (*appconfig.Config, []byte, error)
- func SafeQuotaRequestID(value string) string
- func SanitizeUsagePayloadSecrets(payload string) (string, error)
- func UsagePayloadWithRuntimeMetadata(payload string, metadata UsageRuntimeMetadata) (string, error)
- func ValidateBillingModelPriceImportPreviewInput(input BillingModelPriceImportPreviewInput) error
- func ValidateCredentialConcurrencyLifecycle(nodeHeartbeatTimeout time.Duration, cfg config.CredentialConcurrencyConfig) error
- type APIKeyAdminUpdate
- type APIKeyEntry
- type APIKeyEntryUpdate
- type APIKeyRecord
- type APIKeySelector
- type APIKeyUpsertStats
- type APIKeyUserUpdate
- type AppLogQuery
- type AppLogQueryResult
- type AppLogRecord
- type AuthConcurrencyPatchRequest
- type AuthIndex
- type AuthRecord
- type BillingBalanceQuery
- type BillingBalanceRecord
- type BillingBalanceResult
- type BillingBalanceUpdate
- type BillingChargeQuery
- type BillingChargeRecord
- type BillingChargeResult
- type BillingModelPriceImportAlias
- type BillingModelPriceImportApplyInput
- type BillingModelPriceImportCatalog
- type BillingModelPriceImportCatalogModel
- type BillingModelPriceImportContextBand
- type BillingModelPriceImportCost
- type BillingModelPriceImportMatchOverride
- type BillingModelPriceImportMultiplierRule
- type BillingModelPriceImportOperation
- type BillingModelPriceImportOperationRecord
- type BillingModelPriceImportOperationRowResult
- type BillingModelPriceImportPolicy
- type BillingModelPriceImportPreview
- type BillingModelPriceImportPreviewInput
- type BillingModelPriceImportPreviewRecord
- type BillingModelPriceImportPreviewRow
- type BillingModelPriceImportReason
- type BillingModelPriceImportRuleSnapshot
- type BillingModelPriceImportSummary
- type BillingModelPriceImportTarget
- type BillingModelPriceImportWriteRule
- type BillingModelPricePatch
- type BillingModelPriceQuery
- type BillingModelPriceRecord
- type BillingModelPriceUpdate
- type BillingOverview
- type BillingOverviewQuery
- type BillingPriceSnapshot
- type BillingRange
- type BillingSettings
- type BillingSettingsPatch
- type BillingTierDiagnostics
- type BillingTopItem
- type BillingTrendPoint
- type CPAInFlightSnapshotAttemptRecord
- type CPAInFlightSnapshotPartRecord
- type CPAInFlightSnapshotRecord
- type CPANodeMembershipRecord
- type CPANodeParticipationRecord
- type CPANodeQuiescenceRecord
- type CPANodeRecord
- type CertificateRecord
- type ChannelGroupDetailFilter
- type ChannelGroupDetailRecord
- type ChannelGroupDetailUpdate
- type ChannelGroupRecord
- type ChannelGroupUpdate
- type ClusterEventRecord
- type ClusterNodeRecord
- type ConcurrencyActivationGateRecord
- type ConcurrencyAdmissionError
- type ConcurrencyAdmissionRequest
- type ConcurrencyAdmissionResult
- type ConcurrencyCredentialReferenceChecker
- type ConcurrencyObservationBarrierRecord
- type ConcurrencyPolicyPatch
- type ConcurrencyReleaseRequest
- type Config
- type ConfigRecord
- type ConnectionLifetime
- type Coordinator
- func (c *Coordinator) CurrentMaster(ctx context.Context) (*ClusterNodeRecord, error)
- func (c *Coordinator) HomeIncarnation() (HomeIncarnationID, bool)
- func (c *Coordinator) Initialize(ctx context.Context) error
- func (c *Coordinator) IsMaster() bool
- func (c *Coordinator) NodeSecret() string
- func (c *Coordinator) RetireHomeIncarnation(ctx context.Context) error
- func (c *Coordinator) SetOnMasterChanged(callback func(bool))
- func (c *Coordinator) Start(ctx context.Context) error
- func (c *Coordinator) UpdateClientCount(ctx context.Context, clientCount int) error
- type CoordinatorOptions
- type CredentialConcurrencyCounterRecord
- type CredentialConcurrencyExchangePolicy
- type CredentialConcurrencyModelPolicyRecord
- type CredentialConcurrencyModelState
- type CredentialConcurrencyPolicy
- type CredentialConcurrencyPolicyRecord
- type CredentialConcurrencyState
- type CredentialConfigCounts
- type CredentialReferenceChecker
- type DatabaseBackend
- type DatabaseSnapshotExportOptions
- type DatabaseSnapshotImportResult
- type DatabaseSnapshotImportTableResult
- type DatabaseSnapshotManifest
- type DatabaseSnapshotManifestTable
- type DatabaseSnapshotProgress
- type EventWatcher
- type ExportOptions
- type ExportStats
- type HomeIncarnationID
- type HomeProcessIncarnationRecord
- type ImportOptions
- type ImportStats
- type InFlightAccountedStatus
- type InFlightAggregate
- type InFlightFrameKind
- type InFlightIngestIdentity
- type InFlightIngestResult
- type InFlightLimits
- type InFlightObservationReadModel
- type InFlightObservedCredentialItem
- type InFlightObservedModelItem
- type InFlightRequestDetail
- type InFlightSnapshotCursor
- type InFlightSnapshotCursorInput
- type InFlightSnapshotFrame
- type InFlightSnapshotPayload
- type JSONB
- type KVGetResult
- type KVRecord
- type KVSetMode
- type LifecycleConfigRecord
- type ManagementInFlightSnapshotCursorItemRecord
- type ManagementInFlightSnapshotCursorObservedRecord
- type ManagementInFlightSnapshotCursorRecord
- type ManagementInFlightSnapshotCursorStateModelRecord
- type ManagementInFlightSnapshotCursorStateRecord
- type ModelGroupDetailFilter
- type ModelGroupDetailRecord
- type ModelGroupDetailUpdate
- type ModelGroupRecord
- type ModelGroupUpdate
- type NodeConfig
- type NodeIdentity
- type OAuthSessionRecord
- type OptionalFloatUpdate
- type OptionalLimit
- type OptionalModelLimitMap
- type PGSQLConfig
- type PeriodLimitConfigError
- type PluginStatusRecord
- type PluginStoreAuthKeyRecord
- type PluginStoreAuthRecord
- type PluginStoreAuthSealFunc
- type PluginTaskRecord
- type ProxyPoolPatch
- type ProxyPoolRecord
- type ProxyPoolUpdate
- type QuotaCollectionError
- type QuotaCredentialSnapshot
- type QuotaFacetOption
- type QuotaFacets
- type QuotaListQuery
- type QuotaListResult
- type QuotaPlan
- type QuotaResetCredit
- type QuotaResetCredits
- type QuotaRuntime
- type QuotaSnapshotRecord
- type QuotaSnapshotWrite
- type QuotaSummary
- type QuotaWindow
- type QuotaWindowRecord
- type RESPHandler
- func (h *RESPHandler) BeginFingerprintCancellation(ctx context.Context, fingerprint string) (int64, error)
- func (h *RESPHandler) ClassifyConnection(ctx context.Context, fingerprint string) (ConnectionLifetime, error)
- func (h *RESPHandler) Handle(ctx context.Context, args []string, remoteIP string) ([]byte, error)
- func (h *RESPHandler) RefreshCPALiveness(ctx context.Context, lifetime ConnectionLifetime) error
- func (h *RESPHandler) RequestClientCertificate(ctx context.Context, certificateID string, enrollmentSecret string, ...) ([]byte, error)
- func (h *RESPHandler) SubscribeMembership(ctx context.Context, fingerprint string, nodeID string, protocolVersion int, ...) (ConnectionLifetime, error)
- func (h *RESPHandler) UpdateClientCount(ctx context.Context, clientCount int) error
- type RefreshController
- type Repository
- func (r *Repository) AcknowledgeQuiescence(ctx context.Context, fingerprint string, connectedAt time.Time, revision int64, ...) error
- func (r *Repository) AdmitCredentialConcurrency(ctx context.Context, req ConcurrencyAdmissionRequest) (ConcurrencyAdmissionResult, error)
- func (r *Repository) AllowUserSecurityActionWithRetry(ctx context.Context, action string, scopeHash string, limit int, ...) (bool, time.Duration, error)
- func (r *Repository) AllowedAuthIDsForAPIKey(ctx context.Context, apiKey string) ([]string, error)
- func (r *Repository) AllowedDispatchIDsForAPIKey(ctx context.Context, apiKey string) ([]string, []string, error)
- func (r *Repository) AllowedDispatchIDsForAPIKeyModel(ctx context.Context, apiKey string, modelID string) ([]string, []string, error)
- func (r *Repository) AllowedModelIDsForAPIKey(ctx context.Context, apiKey string) ([]string, error)
- func (r *Repository) AppendAppLog(ctx context.Context, clientIP string, homeIP string, payload string) (*AppLogRecord, error)
- func (r *Repository) AppendEvent(ctx context.Context, scope, op, entity string, version int64) error
- func (r *Repository) AppendUsage(ctx context.Context, payload string, homeIP string) (*UsageRecord, error)
- func (r *Repository) AppendUsageWithRuntime(ctx context.Context, payload string, metadata UsageRuntimeMetadata) (*UsageRecord, error)
- func (r *Repository) ApplyBillingBalanceRecord(ctx context.Context, update BillingBalanceUpdate) (*BillingBalanceRecord, error)
- func (r *Repository) ApplyBillingModelPriceImport(ctx context.Context, input BillingModelPriceImportApplyInput) (*BillingModelPriceImportOperation, error)
- func (r *Repository) ApplyConcurrencyRelease(ctx context.Context, req ConcurrencyReleaseRequest) error
- func (r *Repository) BeginFingerprintCancellation(ctx context.Context, fingerprint string) (int64, error)
- func (r *Repository) BillingOverview(ctx context.Context, query BillingOverviewQuery) (BillingOverview, error)
- func (r *Repository) BuildUserPeriodLimitsStatus(ctx context.Context, userID uint, now time.Time) (UserPeriodLimitsStatus, error)
- func (r *Repository) ClaimEligibleQuotaProbe(ctx context.Context, credentialID string, owner string, now time.Time, ...) (bool, error)
- func (r *Repository) ClaimQuotaProbe(ctx context.Context, credentialID string, owner string, now time.Time, ...) (bool, error)
- func (r *Repository) ClaimUserMailJob(ctx context.Context, workerID string, now time.Time, lease time.Duration) (*UserMailJobRecord, error)
- func (r *Repository) ClassifyConnection(ctx context.Context, fingerprint string, home HomeIncarnationID) (ConnectionLifetime, error)
- func (r *Repository) CleanupExpiredInFlightStaging(ctx context.Context, retention time.Duration) error
- func (r *Repository) CleanupInFlightLifetime(ctx context.Context, fingerprint string, connectedAt time.Time) error
- func (r *Repository) CleanupStaleMemberships(ctx context.Context) error
- func (r *Repository) ClientCertificateFingerprintActive(ctx context.Context, certificateID string, fingerprint string) (bool, error)
- func (r *Repository) ClusterCAKeyPair(ctx context.Context) (*x509.Certificate, *rsa.PrivateKey, error)
- func (r *Repository) CompleteFingerprintCancellation(ctx context.Context, fingerprint string, connectedAt time.Time, revision int64) error
- func (r *Repository) CompleteOAuthSession(ctx context.Context, state string) error
- func (r *Repository) CompleteUserMailJob(ctx context.Context, jobID uint, workerID string, now time.Time) error
- func (r *Repository) ConsumeUserEmailVerificationToken(ctx context.Context, tokenHash string, now time.Time) (*UserRecord, error)
- func (r *Repository) ConsumeUserPasswordResetToken(ctx context.Context, tokenHash string, passwordHash string, now time.Time) (*UserRecord, error)
- func (r *Repository) CreateAPIKey(ctx context.Context, update APIKeyEntryUpdate) (*APIKeyRecord, error)
- func (r *Repository) CreateAPIKeyForUser(ctx context.Context, userID uint, update APIKeyUserUpdate) (*APIKeyRecord, error)
- func (r *Repository) CreateBillingModelPrice(ctx context.Context, update BillingModelPriceUpdate) (*BillingModelPriceRecord, error)
- func (r *Repository) CreateBillingModelPriceImportPreview(ctx context.Context, input BillingModelPriceImportPreviewInput, ...) (*BillingModelPriceImportPreview, error)
- func (r *Repository) CreateChannelGroup(ctx context.Context, channelName string, disabled bool) (*ChannelGroupRecord, error)
- func (r *Repository) CreateChannelGroupDetail(ctx context.Context, channelGroupID uint, authID string) (*ChannelGroupDetailRecord, error)
- func (r *Repository) CreateHomeJWT(ctx context.Context, certificateID string, ip string, port int, ...) (string, error)
- func (r *Repository) CreateInFlightSnapshotCursor(ctx context.Context, input InFlightSnapshotCursorInput, ttl time.Duration) (InFlightSnapshotCursor, error)
- func (r *Repository) CreateModelGroup(ctx context.Context, groupName string, disabled bool) (*ModelGroupRecord, error)
- func (r *Repository) CreateModelGroupDetail(ctx context.Context, modelGroupID uint, modelID string, channels []uint) (*ModelGroupDetailRecord, error)
- func (r *Repository) CreatePendingClientCertificate(ctx context.Context) (string, string, error)
- func (r *Repository) CreatePluginStoreAuth(ctx context.Context, record *PluginStoreAuthRecord, ...) error
- func (r *Repository) CreatePluginTask(ctx context.Context, task node.PluginTask) (node.PluginTask, error)
- func (r *Repository) CreateProxyPoolItem(ctx context.Context, update ProxyPoolUpdate) (*ProxyPoolRecord, error)
- func (r *Repository) CreateUser(ctx context.Context, update UserUpdate) (*UserRecord, error)
- func (r *Repository) CurrentMasterNode(ctx context.Context) (*ClusterNodeRecord, error)
- func (r *Repository) DeleteAPIKey(ctx context.Context, selector APIKeySelector) error
- func (r *Repository) DeleteAPIKeyForUser(ctx context.Context, userID uint, id uint, apiKey string) error
- func (r *Repository) DeleteAppLogs(ctx context.Context) (int64, error)
- func (r *Repository) DeleteBillingModelPrice(ctx context.Context, id string) error
- func (r *Repository) DeleteChannelGroup(ctx context.Context, id uint) error
- func (r *Repository) DeleteChannelGroupDetail(ctx context.Context, id uint) error
- func (r *Repository) DeleteModelGroup(ctx context.Context, id uint) error
- func (r *Repository) DeleteModelGroupDetail(ctx context.Context, id uint) error
- func (r *Repository) DeletePluginStoreAuth(ctx context.Context, id uint) error
- func (r *Repository) DeleteProxyPoolItem(ctx context.Context, id string) error
- func (r *Repository) DeleteUser(ctx context.Context, id uint) error
- func (r *Repository) DialectName() string
- func (r *Repository) EnqueueUserMailJob(ctx context.Context, userID uint, purpose string, emailVersion uint64, ...) (*UserMailJobRecord, error)
- func (r *Repository) EnsureClusterCertificates(ctx context.Context, ip string) (*tls.Config, error)
- func (r *Repository) EnsureLifecycleConfig(ctx context.Context, nodeHeartbeatTimeout time.Duration) (LifecycleConfigRecord, error)
- func (r *Repository) EnsurePluginStoreAuthKey(ctx context.Context) ([]byte, int, error)
- func (r *Repository) ExportCredentialConcurrencyPolicies(ctx context.Context, root map[string]any) error
- func (r *Repository) FailQuotaProbe(ctx context.Context, credentialID string, owner string, ...) error
- func (r *Repository) FailQuotaProbeAt(ctx context.Context, credentialID string, owner string, ...) error
- func (r *Repository) FailUserMailJob(ctx context.Context, job *UserMailJobRecord, workerID string, errorCode string, ...) error
- func (r *Repository) FenceHomeIncarnation(ctx context.Context, id HomeIncarnationID, reason string) error
- func (r *Repository) ForceClaimEligibleQuotaProbe(ctx context.Context, credentialID string, owner string, now time.Time, ...) (bool, error)
- func (r *Repository) GetAuth(ctx context.Context, uuid string) (*coreauth.Auth, *AuthRecord, error)
- func (r *Repository) GetBillingModelPrice(ctx context.Context, id string) (*BillingModelPriceRecord, error)
- func (r *Repository) GetBillingModelPriceImportOperation(ctx context.Context, id string) (*BillingModelPriceImportOperation, error)
- func (r *Repository) GetBillingSettings(ctx context.Context) (BillingSettings, error)
- func (r *Repository) GetBillingTierDiagnostics(ctx context.Context) (BillingTierDiagnostics, error)
- func (r *Repository) GetChannelGroup(ctx context.Context, id uint) (*ChannelGroupRecord, error)
- func (r *Repository) GetChannelGroupDetail(ctx context.Context, id uint) (*ChannelGroupDetailRecord, error)
- func (r *Repository) GetCredentialConcurrencyPolicy(ctx context.Context, credentialID string) (CredentialConcurrencyPolicy, error)
- func (r *Repository) GetModelGroup(ctx context.Context, id uint) (*ModelGroupRecord, error)
- func (r *Repository) GetModelGroupDetail(ctx context.Context, id uint) (*ModelGroupDetailRecord, error)
- func (r *Repository) GetOAuthSession(ctx context.Context, state string) (*OAuthSessionRecord, error)
- func (r *Repository) GetPluginStoreAuth(ctx context.Context, id uint) (*PluginStoreAuthRecord, error)
- func (r *Repository) GetProxyPoolItem(ctx context.Context, id string) (*ProxyPoolRecord, error)
- func (r *Repository) GetQuotaCredential(ctx context.Context, credentialID string, now time.Time) (*QuotaCredentialSnapshot, error)
- func (r *Repository) GetUsageObservabilityPayloadSummary(ctx context.Context, id string) (*UsageObservabilityPayloadSummary, error)
- func (r *Repository) GetUsageObservabilityRecord(ctx context.Context, id string) (*UsageObservabilityRecord, error)
- func (r *Repository) GetUser(ctx context.Context, id uint) (*UserRecord, error)
- func (r *Repository) GetUserByEmail(ctx context.Context, email string) (*UserRecord, error)
- func (r *Repository) GetUserByUsername(ctx context.Context, username string) (*UserRecord, error)
- func (r *Repository) HeartbeatHomeIncarnation(ctx context.Context, id HomeIncarnationID) error
- func (r *Repository) ImportCredentialConcurrencyPolicies(ctx context.Context, root map[string]any) error
- func (r *Repository) ImportCredentialConcurrencyPoliciesTx(ctx context.Context, tx *gorm.DB, root map[string]any) error
- func (r *Repository) IngestInFlightFrame(ctx context.Context, identity InFlightIngestIdentity, raw []byte, ...) (InFlightIngestResult, error)
- func (r *Repository) InvalidateUserSecurityTokenHash(ctx context.Context, tokenHash string, now time.Time) error
- func (r *Repository) KVDel(ctx context.Context, keys []string) (int64, error)
- func (r *Repository) KVExpire(ctx context.Context, key string, ttl time.Duration) (bool, error)
- func (r *Repository) KVGet(ctx context.Context, key string) ([]byte, bool, error)
- func (r *Repository) KVIncrBy(ctx context.Context, key string, delta int64) (int64, error)
- func (r *Repository) KVMGet(ctx context.Context, keys []string) ([]KVGetResult, error)
- func (r *Repository) KVMSet(ctx context.Context, pairs map[string][]byte) error
- func (r *Repository) KVPurgeExpired(ctx context.Context, now time.Time, limit int) (int64, error)
- func (r *Repository) KVSet(ctx context.Context, key string, value []byte, ttl time.Duration, ...) (bool, error)
- func (r *Repository) KVTTL(ctx context.Context, key string) (int64, error)
- func (r *Repository) LifecycleConfig(ctx context.Context) (config.CredentialConcurrencyConfig, error)
- func (r *Repository) ListAPIKeyEntries(ctx context.Context) ([]APIKeyEntry, error)
- func (r *Repository) ListAPIKeyRecordsForUser(ctx context.Context, userID uint) ([]APIKeyRecord, error)
- func (r *Repository) ListAppLogs(ctx context.Context, opts AppLogQuery) (AppLogQueryResult, error)
- func (r *Repository) ListAuthIndex(ctx context.Context) ([]AuthIndex, error)
- func (r *Repository) ListAuths(ctx context.Context) ([]*coreauth.Auth, error)
- func (r *Repository) ListAuthsUnscoped(ctx context.Context, tx *gorm.DB) ([]*coreauth.Auth, error)
- func (r *Repository) ListBillingBalanceRecords(ctx context.Context, query BillingBalanceQuery) (BillingBalanceResult, error)
- func (r *Repository) ListBillingCharges(ctx context.Context, query BillingChargeQuery) (BillingChargeResult, error)
- func (r *Repository) ListBillingModelPrices(ctx context.Context, query BillingModelPriceQuery) ([]BillingModelPriceRecord, error)
- func (r *Repository) ListCPANodeSnapshots(ctx context.Context, cutoff time.Time) ([]CPANodeRecord, error)
- func (r *Repository) ListChannelGroupDetails(ctx context.Context, filter ChannelGroupDetailFilter) ([]ChannelGroupDetailRecord, error)
- func (r *Repository) ListChannelGroups(ctx context.Context) ([]ChannelGroupRecord, error)
- func (r *Repository) ListClusterNodes(ctx context.Context, cutoff time.Time) ([]ClusterNodeRecord, error)
- func (r *Repository) ListCredentialConcurrencyPolicies(ctx context.Context) ([]CredentialConcurrencyPolicy, error)
- func (r *Repository) ListLiveCPANodes(ctx context.Context, cutoff time.Time) ([]CPANodeRecord, error)
- func (r *Repository) ListLiveClusterNodes(ctx context.Context, cutoff time.Time) ([]ClusterNodeRecord, error)
- func (r *Repository) ListModelGroupDetails(ctx context.Context, filter ModelGroupDetailFilter) ([]ModelGroupDetailRecord, error)
- func (r *Repository) ListModelGroups(ctx context.Context) ([]ModelGroupRecord, error)
- func (r *Repository) ListPendingPluginTasks(ctx context.Context, nodeType string, nodeID string) ([]node.PluginTask, error)
- func (r *Repository) ListPendingQuiescence(ctx context.Context, home HomeIncarnationID) ([]CPANodeQuiescenceRecord, error)
- func (r *Repository) ListPluginStatuses(ctx context.Context, nodeType string) ([]node.PluginTaskStatus, error)
- func (r *Repository) ListPluginStoreAuth(ctx context.Context) ([]PluginStoreAuthRecord, error)
- func (r *Repository) ListProxyPoolItems(ctx context.Context) ([]ProxyPoolRecord, error)
- func (r *Repository) ListQuotaCredentials(ctx context.Context, query QuotaListQuery) (QuotaListResult, error)
- func (r *Repository) ListUsageObservabilityAggregates(ctx context.Context, query UsageObservabilityAggregateQuery) (UsageObservabilityAggregateResult, error)
- func (r *Repository) ListUsageObservabilityRecords(ctx context.Context, query UsageObservabilityRecordQuery) (UsageObservabilityRecordListResult, error)
- func (r *Repository) ListUsers(ctx context.Context) ([]UserRecord, error)
- func (r *Repository) LiveClusterNodeByIPAndSecret(ctx context.Context, ip string, secret string, cutoff time.Time) (*ClusterNodeRecord, error)
- func (r *Repository) LoadConfigAsRuntimeConfig(ctx context.Context) (*appconfig.Config, []byte, error)
- func (r *Repository) LoadConfigSnapshot(ctx context.Context) (map[string]json.RawMessage, error)
- func (r *Repository) LockActiveConcurrencyLifetimeTx(ctx context.Context, tx *gorm.DB, lifetime ConnectionLifetime) error
- func (r *Repository) MarkProxyPoolTestResult(ctx context.Context, id string, result string, testedAt time.Time) (*ProxyPoolRecord, error)
- func (r *Repository) MaxEventID(ctx context.Context) (int64, error)
- func (r *Repository) MergeOAuthSessionData(ctx context.Context, state string, values map[string]any) error
- func (r *Repository) MutateAuth(ctx context.Context, uuid string, op string, ...) (*coreauth.Auth, *AuthRecord, bool, error)
- func (r *Repository) PatchAuthAndConcurrency(ctx context.Context, request AuthConcurrencyPatchRequest) error
- func (r *Repository) PatchCredentialConcurrencyPolicy(ctx context.Context, credentialID string, patch ConcurrencyPolicyPatch, ...) (CredentialConcurrencyPolicy, error)
- func (r *Repository) PatchProxyPoolItem(ctx context.Context, id string, patch ProxyPoolPatch) (*ProxyPoolRecord, error)
- func (r *Repository) PluginStoreAuthRevision(ctx context.Context) (int64, error)
- func (r *Repository) PurgeExpiredUserSecurity(ctx context.Context, now time.Time, retention time.Duration) error
- func (r *Repository) ReadConcurrencyState(ctx context.Context) ([]CredentialConcurrencyState, error)
- func (r *Repository) ReadInFlightObservation(ctx context.Context, staleAfter time.Duration) (InFlightObservationReadModel, error)
- func (r *Repository) ReadInFlightSnapshotCursorPage(ctx context.Context, cursor string, credentialID string, model string, ...) (InFlightSnapshotCursor, error)
- func (r *Repository) ReconcileProviderAuths(ctx context.Context, key string, next []*coreauth.Auth, ...) error
- func (r *Repository) RecordParticipation(ctx context.Context, lifetime ConnectionLifetime) error
- func (r *Repository) RecoverStaleQuiescence(ctx context.Context) error
- func (r *Repository) RefreshCPALiveness(ctx context.Context, lifetime ConnectionLifetime) error
- func (r *Repository) RegisterHomeIncarnation(ctx context.Context, ip string, port int, capabilities []string) (HomeIncarnationID, error)
- func (r *Repository) RenewUserMailJobClaim(ctx context.Context, jobID uint, workerID string, now time.Time, ...) error
- func (r *Repository) ReplaceAPIKeyEntries(ctx context.Context, entries []APIKeyEntryUpdate) (APIKeyUpsertStats, error)
- func (r *Repository) ReplaceCPANodeSnapshot(ctx context.Context, homeIP string, homePort int, nodes []node.Node, ...) error
- func (r *Repository) ReplaceCPANodeSnapshotForIncarnation(ctx context.Context, home HomeIncarnationID, nodes []node.Node, ...) error
- func (r *Repository) ReplaceConfigSnapshot(ctx context.Context, values map[string]any) error
- func (r *Repository) ReplaceConfigSnapshotAndCreatePluginTask(ctx context.Context, values map[string]any, task node.PluginTask) (node.PluginTask, error)
- func (r *Repository) ReplaceConfigSnapshotWithLifecycleConfig(ctx context.Context, nodeHeartbeatTimeout time.Duration, values map[string]any) error
- func (r *Repository) ReplaceConfigSnapshotWithLifecycleConfigAndCreatePluginTask(ctx context.Context, nodeHeartbeatTimeout time.Duration, values map[string]any, ...) (node.PluginTask, error)
- func (r *Repository) ReplacePluginStatus(ctx context.Context, nodeType string, status node.PluginTaskStatus) error
- func (r *Repository) ReplaceUserSecurityToken(ctx context.Context, record UserSecurityTokenRecord) error
- func (r *Repository) ReplaceUserSecurityTokenForMailJob(ctx context.Context, jobID uint, workerID string, ...) error
- func (r *Repository) RequireActiveCPAMembership(ctx context.Context, tx *gorm.DB, identity InFlightIngestIdentity) (CPANodeMembershipRecord, error)
- func (r *Repository) ResetUserPeriodLimits(ctx context.Context, userID uint, windows []string, mode string, now time.Time) (UserPeriodLimitResetResult, error)
- func (r *Repository) RetireHomeIncarnation(ctx context.Context, id HomeIncarnationID) error
- func (r *Repository) RetireProviderAuth(ctx context.Context, credentialID string) error
- func (r *Repository) RunUsageCacheReadBackfillBatch(ctx context.Context) (UsageCacheReadBackfillResult, error)
- func (r *Repository) RunUsageDerivedColumnBackfillBatch(ctx context.Context) (UsageDerivedColumnBackfillResult, error)
- func (r *Repository) RunUsageTokenAccountingBackfillBatch(ctx context.Context) (UsageTokenAccountingBackfillResult, error)
- func (r *Repository) SetOAuthSessionError(ctx context.Context, state string, message string) error
- func (r *Repository) SignClientCertificateRequest(ctx context.Context, certificateID string, enrollmentSecret string, ...) ([]byte, []byte, error)
- func (r *Repository) SignClientCertificateRequestJSON(ctx context.Context, certificateID string, enrollmentSecret string, ...) ([]byte, error)
- func (r *Repository) SoftDeleteAuth(ctx context.Context, uuid string) error
- func (r *Repository) SubscribeMembership(ctx context.Context, request SubscribeMembershipRequest) (CPANodeMembershipRecord, error)
- func (r *Repository) SumUserChargeAmountSince(ctx context.Context, userID uint, since time.Time) (float64, error)
- func (r *Repository) SupersedeUserMailJob(ctx context.Context, jobID uint, workerID string, now time.Time) error
- func (r *Repository) UpdateAPIKey(ctx context.Context, selector APIKeySelector, update APIKeyAdminUpdate) (*APIKeyRecord, error)
- func (r *Repository) UpdateAPIKeyBindings(ctx context.Context, apiKey string, userID *uint, channels *[]uint, ...) (*APIKeyRecord, error)
- func (r *Repository) UpdateAPIKeyChannels(ctx context.Context, apiKey string, channels []uint) (*APIKeyRecord, error)
- func (r *Repository) UpdateAPIKeyForUser(ctx context.Context, userID uint, id uint, apiKey string, ...) (*APIKeyRecord, error)
- func (r *Repository) UpdateBillingModelPrice(ctx context.Context, id string, patch BillingModelPricePatch) (*BillingModelPriceRecord, error)
- func (r *Repository) UpdateBillingSettings(ctx context.Context, patch BillingSettingsPatch) (BillingSettings, error)
- func (r *Repository) UpdateChannelGroup(ctx context.Context, id uint, update ChannelGroupUpdate) (*ChannelGroupRecord, error)
- func (r *Repository) UpdateChannelGroupDetail(ctx context.Context, id uint, update ChannelGroupDetailUpdate) (*ChannelGroupDetailRecord, error)
- func (r *Repository) UpdateLifecycleConfig(ctx context.Context, nodeHeartbeatTimeout time.Duration, ...) (int64, error)
- func (r *Repository) UpdateModelGroup(ctx context.Context, id uint, update ModelGroupUpdate) (*ModelGroupRecord, error)
- func (r *Repository) UpdateModelGroupDetail(ctx context.Context, id uint, update ModelGroupDetailUpdate) (*ModelGroupDetailRecord, error)
- func (r *Repository) UpdatePluginStoreAuth(ctx context.Context, record *PluginStoreAuthRecord) error
- func (r *Repository) UpdateProxyPoolItem(ctx context.Context, id string, update ProxyPoolUpdate) (*ProxyPoolRecord, error)
- func (r *Repository) UpdateUser(ctx context.Context, id uint, update UserUpdate) (*UserRecord, error)
- func (r *Repository) UpsertAPIKeys(ctx context.Context, keys []string) (APIKeyUpsertStats, error)
- func (r *Repository) UpsertAuth(ctx context.Context, auth *coreauth.Auth, op string) (*AuthRecord, error)
- func (r *Repository) UpsertAuthPreservingDisabled(ctx context.Context, auth *coreauth.Auth, op string) (*AuthRecord, error)
- func (r *Repository) UpsertAuthWithResult(ctx context.Context, auth *coreauth.Auth, op string) (*AuthRecord, UpsertResult, error)
- func (r *Repository) UpsertConfigValue(ctx context.Context, key string, value any) error
- func (r *Repository) UpsertConfigValueWithResult(ctx context.Context, key string, value any) (UpsertResult, error)
- func (r *Repository) UpsertOAuthSession(ctx context.Context, record *OAuthSessionRecord) error
- func (r *Repository) UpsertQuotaSnapshot(ctx context.Context, input QuotaSnapshotWrite) (bool, error)
- func (r *Repository) UsageObservabilityFilterOptions(ctx context.Context, query UsageObservabilityRecordQuery) (UsageObservabilityFilterOptions, error)
- func (r *Repository) UsageObservabilityHealthDetails(ctx context.Context, query UsageObservabilityRecordQuery, subject string) (map[string]UsageObservabilityHealthDetail, error)
- func (r *Repository) UsageObservabilityOverview(ctx context.Context, query UsageObservabilityOverviewQuery) (UsageObservabilityOverview, error)
- func (r *Repository) UsageObservabilityRealtime(ctx context.Context, query UsageObservabilityRealtimeQuery) (UsageObservabilityRealtimeSnapshot, error)
- func (r *Repository) UsageTokenBreakdownV2Ready(ctx context.Context) (bool, error)
- func (r *Repository) ValidateAPIKey(ctx context.Context, apiKey string) (bool, error)
- func (r *Repository) WithAuthRefreshLock(ctx context.Context, uuid string, ...) (*coreauth.Auth, error)
- func (r *Repository) WithConcurrencyActivationGate(ctx context.Context, fn func(*gorm.DB, *ConcurrencyActivationGateRecord) error) error
- type RuntimeAdapter
- func (a *RuntimeAdapter) AllowedAuthIDsForAPIKey(ctx context.Context, apiKey string) ([]string, error)
- func (a *RuntimeAdapter) AllowedDispatchIDsForAPIKey(ctx context.Context, apiKey string) ([]string, []string, error)
- func (a *RuntimeAdapter) AllowedDispatchIDsForAPIKeyModel(ctx context.Context, apiKey string, modelID string) ([]string, []string, error)
- func (a *RuntimeAdapter) AllowedModelIDsForAPIKey(ctx context.Context, apiKey string) ([]string, error)
- func (a *RuntimeAdapter) ApplyEvent(ctx context.Context, event ClusterEventRecord) error
- func (a *RuntimeAdapter) Delete(ctx context.Context, id string) error
- func (a *RuntimeAdapter) Enabled() bool
- func (a *RuntimeAdapter) GetFullAuth(ctx context.Context, uuid string) (*coreauth.Auth, error)
- func (a *RuntimeAdapter) InvalidateFullAuth(uuid string)
- func (a *RuntimeAdapter) KVDel(ctx context.Context, keys []string) (int64, error)
- func (a *RuntimeAdapter) KVExpire(ctx context.Context, key string, ttl time.Duration) (bool, error)
- func (a *RuntimeAdapter) KVGet(ctx context.Context, key string) ([]byte, bool, error)
- func (a *RuntimeAdapter) KVIncrBy(ctx context.Context, key string, delta int64) (int64, error)
- func (a *RuntimeAdapter) KVMGet(ctx context.Context, keys []string) ([]home.KVGetResult, error)
- func (a *RuntimeAdapter) KVMSet(ctx context.Context, pairs map[string][]byte) error
- func (a *RuntimeAdapter) KVPurgeExpired(ctx context.Context, now time.Time, limit int) (int64, error)
- func (a *RuntimeAdapter) KVSet(ctx context.Context, key string, value []byte, ttl time.Duration, mode string) (bool, error)
- func (a *RuntimeAdapter) KVTTL(ctx context.Context, key string) (int64, error)
- func (a *RuntimeAdapter) List(ctx context.Context) ([]*coreauth.Auth, error)
- func (a *RuntimeAdapter) ListMinimalAuths() []*coreauth.Auth
- func (a *RuntimeAdapter) ListPendingPluginTasks(ctx context.Context, nodeType string, nodeID string) ([]node.PluginTask, error)
- func (a *RuntimeAdapter) LoadAuthIndex(ctx context.Context) error
- func (a *RuntimeAdapter) LoadConfigYAML(ctx context.Context) ([]byte, error)
- func (a *RuntimeAdapter) LoadIndex(ctx context.Context) error
- func (a *RuntimeAdapter) MutateAuthState(ctx context.Context, id string, mutate func(auth *coreauth.Auth) bool) (*coreauth.Auth, error)
- func (a *RuntimeAdapter) RefreshAuthIndex(ctx context.Context, uuid string) error
- func (a *RuntimeAdapter) RemoveAuthIndex(uuid string)
- func (a *RuntimeAdapter) ReplacePluginStatus(ctx context.Context, nodeType string, status node.PluginTaskStatus) error
- func (a *RuntimeAdapter) Save(ctx context.Context, auth *coreauth.Auth) (string, error)
- func (a *RuntimeAdapter) SetHomePort(port int)
- func (a *RuntimeAdapter) StoreAppLogPayload(ctx context.Context, clientIP string, payload string) error
- func (a *RuntimeAdapter) StoreUsagePayload(ctx context.Context, payload string) error
- func (a *RuntimeAdapter) ValidateAPIKey(ctx context.Context, apiKey string) (bool, error)
- type SQLiteConfig
- type StartupRecovery
- type SubscribeMembershipRequest
- type UpsertResult
- type UsageCacheReadBackfillResult
- type UsageDerivedColumnBackfillResult
- type UsageObservabilityActivityPoint
- type UsageObservabilityAggregateItem
- type UsageObservabilityAggregateQuery
- type UsageObservabilityAggregateResult
- type UsageObservabilityBilling
- type UsageObservabilityClient
- type UsageObservabilityCostBreakdownItem
- type UsageObservabilityCredential
- type UsageObservabilityError
- type UsageObservabilityFilterOptions
- type UsageObservabilityHealthDetail
- type UsageObservabilityLatencyDistributionBucket
- type UsageObservabilityLiveSummary
- type UsageObservabilityOverview
- type UsageObservabilityOverviewQuery
- type UsageObservabilityOverviewRange
- type UsageObservabilityPayloadSummary
- type UsageObservabilityPerformance
- type UsageObservabilityRealtimeQuery
- type UsageObservabilityRealtimeSnapshot
- type UsageObservabilityRealtimeVelocityPoint
- type UsageObservabilityRecord
- type UsageObservabilityRecordListResult
- type UsageObservabilityRecordQuery
- type UsageObservabilityRuntime
- type UsageObservabilityTokens
- type UsageObservabilityTopGroups
- type UsageObservabilityTotals
- type UsageObservabilityTrendPoint
- type UsageRecord
- type UsageRuntimeMetadata
- type UsageTokenAccountingBackfillResult
- type UsageTokenBreakdown
- type UsageTokenInputBreakdown
- type UsageTokenOutputBreakdown
- type UserMailJobRecord
- type UserPeriodLimitResetResult
- type UserPeriodLimitsStatus
- type UserPeriodWindowStatus
- type UserRecord
- type UserSecurityThrottleRecord
- type UserSecurityTokenRecord
- type UserUpdate
- type ValidatedDatabaseSnapshot
Constants ¶
const ( BillingBalanceTypeRecharge = "recharge" BillingBalanceTypeDeduct = "deduct" BillingPriceSourceManual = "manual" BillingPriceSourceDefault = "default" BillingPriceSourceSync = "sync" BillingServiceTierWildcard = "*" BillingServiceTierSourceRequest = "request" BillingServiceTierSourceResponse = "response" BillingReportTimezoneUTC = "UTC" )
const ( HomeIncarnationActive = "active" HomeIncarnationExpired = "expired" HomeIncarnationRetired = "retired" HomeIncarnationFenced = "fenced" )
const ( InFlightFramePart InFlightFrameKind = "part" InFlightFrameOverflow InFlightFrameKind = "overflow" InFlightAccounted InFlightAccountedStatus = "accounted" InFlightUnaccounted InFlightAccountedStatus = "unaccounted" )
const ( MembershipStateActive = "active" MembershipStateCanceling = "canceling" MembershipStateClosed = "closed" )
const ( ProxyPoolScopeGlobal = "global" ProxyPoolTestResultPassed = "passed" ProxyPoolTestResultFailed = "failed" ProxyPoolTestResultUntested = "untested" )
const ( QuiescenceStatusPending = "pending" QuiescenceStatusAcknowledged = "acknowledged" QuiescenceStatusFenced = "fenced" )
const ( UsageTokenAccountingQualityComplete = "complete" UsageTokenAccountingQualityInconsistent = "inconsistent" UsageTokenAccountingQualityUnclassified = "unclassified" )
const ( UsageObservabilityDefaultRecordLimit = 50 UsageObservabilityMaxRecordLimit = 200 UsageObservabilityDefaultGroupLimit = 20 UsageObservabilityMaxGroupLimit = 100 // UsageObservabilityMaxTrendBuckets bounds each overview trend and its aligned activity series. UsageObservabilityMaxTrendBuckets = 10000 UsageObservabilityCurrencyCredits = "credits" UsageObservabilityBillingBasisCharge = "billing_charge" UsageObservabilityBillingBasisUnknown = "unknown" )
const ( PeriodWindow5h = "5h" PeriodWindow1d = "1d" PeriodWindow7d = "7d" PeriodWindow30d = "30d" // Period window modes (canonical values stored and returned by APIs). // first_use: first billable charge opens a wall-clock duration window. // Aligns with Claude Code / Codex "5h session" + optional weekly layers: // quota is a spend budget inside the window, not wall-clock working time. // sliding: rolling last-N duration (API also accepts "rolling"). // calendar: natural day / week / month (1d/7d/30d only). // "fixed" is a deprecated alias of first_use (name was ambiguous). PeriodWindowModeFirstUse = "first_use" PeriodWindowModeFixed = "fixed" // deprecated alias of first_use PeriodWindowModeSliding = "sliding" PeriodWindowModeRolling = "rolling" // alias of sliding PeriodWindowModeCalendar = "calendar" PeriodResetModeCounter = "counter" PeriodResetModeWindowOnly = "window_only" DefaultUserTimezone = "Asia/Shanghai" DefaultPeriodWindowMode = PeriodWindowModeFirstUse DefaultWeekResetDay = 1 DefaultWeekResetHour = 0 )
const ( PeriodLimitErrInvalidLimit = "invalid_limit" PeriodLimitErrInvalidWindowMode = "invalid_window_mode" PeriodLimitErrInvalidTimezone = "invalid_timezone" PeriodLimitErrInvalidWeekResetDay = "invalid_week_reset_day" PeriodLimitErrInvalidWeekResetHour = "invalid_week_reset_hour" PeriodLimitErrInvalidResetMode = "invalid_reset_mode" PeriodLimitErrInvalidResetWindows = "invalid_reset_windows" )
Stable machine-readable codes for period-limit validation failures. The Management API surfaces them in field_errors so clients can localize and anchor errors without parsing message strings.
const ( UserSecurityTokenPurposeEmailVerification = "verify_email" UserSecurityTokenPurposePasswordReset = "reset_password" UserMailJobStatusPending = "pending" UserMailJobStatusSending = "sending" UserMailJobStatusSent = "sent" UserMailJobStatusFailed = "failed" UserMailJobStatusSuperseded = "superseded" )
const (
BillingModelPriceImportSourceModelsDev = "models.dev"
)
const DefaultConfigPath = "cluster.yaml"
const (
OAuthSessionTTL = 20 * time.Minute
)
const UsageTokenAccountingSchemaVersion = 2
Variables ¶
var ( ErrBillingDuplicateModelPrice = errors.New("billing model price already exists") ErrBillingInvalidModelPrice = errors.New("invalid billing model price") )
var ( ErrBillingImportPreviewNotFound = errors.New("billing import preview not found") ErrBillingImportPreviewExpired = errors.New("billing import preview expired") ErrBillingImportPreviewStale = errors.New("billing import preview stale") ErrBillingImportRuleConflict = errors.New("billing import rule conflict") ErrBillingImportInvalidSelection = errors.New("billing import invalid selection") ErrBillingImportOverwriteRequired = errors.New("billing import overwrite confirmation required") ErrBillingImportIdempotencyConflict = errors.New("billing import idempotency key was reused with a different request") ErrBillingImportOperationNotFound = errors.New("billing import operation not found") )
var ( ErrConcurrencyCounterInvalid = errors.New("credential concurrency counter is invalid") )
var ( ErrConcurrencyCredentialNotFound = errors.New("credential concurrency policy credential not found") ErrConcurrencyDuplicateModel = errors.New("duplicate credential concurrency model") ErrConcurrencyInvalidLimit = errors.New("invalid credential concurrency limit") ErrConcurrencyInvalidModel = errors.New("invalid credential concurrency model") ErrConcurrencyLegacyMembershipActive = errors.New("legacy CPA membership is active") ErrConcurrencyHomeCapabilityMissing = errors.New("active Home lacks credential concurrency limiter capability") ErrConcurrencyPolicyVersionConflict = errors.New("credential concurrency policy version conflict") )
var ( ErrConcurrencyInvalidRelease = errors.New("credential concurrency release is invalid") ErrConcurrencyReleaseExceedsActive = errors.New("credential concurrency release exceeds active count") )
var ( ErrCredentialUUIDMappingRequired = errors.New("credential uuid mapping required") ErrCredentialValidation = errors.New("credential validation failed") ErrCredentialIdentityConflict = errors.New("credential identity conflict") )
var ( ErrConcurrencyHomeCapabilityRequired = errors.New("Home concurrency capability is required") ErrConcurrencySQLiteMultiHome = errors.New("active concurrency limits require a single SQLite Home") ErrHomeIncarnationFenced = errors.New("Home incarnation is fenced") ErrHomeIncarnationNotFound = errors.New("Home incarnation not found") ErrHomeIncarnationInactive = errors.New("Home incarnation is not active") )
var ( ErrInFlightLifetimeMismatch = errors.New("in-flight snapshot lifetime mismatch") ErrInFlightFrameInvalid = errors.New("invalid in-flight snapshot frame") ErrInFlightRevisionStale = errors.New("stale in-flight snapshot revision") ErrInFlightRevisionConflict = errors.New("conflicting in-flight snapshot revision") ErrInFlightRevisionOverflow = errors.New("in-flight snapshot revision overflow") )
var ( ErrDuplicateCPACertificate = errors.New("CPA certificate is already owned by an active membership") ErrConcurrencyProtocolRequired = errors.New("credential concurrency protocol version 1 is required") ErrLifecycleConfigRevisionMismatch = errors.New("lifecycle configuration revision does not match") ErrMembershipNotActive = errors.New("CPA membership is not active") )
var ( ErrQuiescenceRevisionMismatch = errors.New("fingerprint quiescence revision does not match") ErrFingerprintQuiescenceSetIncomplete = errors.New("fingerprint quiescence set is incomplete") ErrFingerprintNotQuiescent = errors.New("fingerprint is not quiescent") )
var ErrAPIKeyExists = errors.New("api key already exists")
ErrAPIKeyExists indicates that an API key value is already owned by another record.
var ErrAPIKeySelectorMismatch = errors.New("api key selector mismatch")
ErrAPIKeySelectorMismatch indicates that multiple selectors do not identify the same API key.
var ErrCredentialConcurrencyOrphan = errors.New("credential concurrency policy would be orphaned")
var ErrInFlightSnapshotCursorExpired = errors.New("in-flight snapshot cursor expired")
var ErrInvalidModelChannelGroupID = errors.New("model channel group id must be greater than zero")
ErrInvalidModelChannelGroupID indicates that a model detail channel binding contains ID zero.
var ErrLifecycleConfigInUse = errors.New("lifecycle configuration is in use")
var ErrOAuthSessionNotPending = errors.New("oauth session is not pending")
ErrOAuthSessionNotPending reports that session data can no longer be changed.
var ErrPluginStoreAuthConflict = errors.New("plugin store auth update conflict")
ErrPluginStoreAuthConflict indicates an optimistic update conflict.
var ErrQuotaProbeLeaseLost = errors.New("quota probe lease is no longer owned")
ErrQuotaProbeLeaseLost reports that an in-flight probe no longer owns its completion lease.
var ErrUsageObservabilityTooManyTrendBuckets = errors.New("usage overview trend bucket limit exceeded")
ErrUsageObservabilityTooManyTrendBuckets indicates that the applied range and interval exceed the response limit.
var ErrUserMailJobClaimLost = errors.New("user mail job claim is no longer active")
var ErrUserNotFound = errors.New("user not found")
ErrUserNotFound indicates that the referenced user record does not exist.
var ErrUserSecurityTokenInvalid = errors.New("user security token is invalid or expired")
Functions ¶
func ApplyOriginalAuthFileName ¶
ApplyOriginalAuthFileName stores the source OAuth file name for management display.
func CanonicalPeriodWindowMode ¶ added in v1.0.63
CanonicalPeriodWindowMode returns the stored/API mode for display. Unknown values fall back to the default first_use mode.
func ClientAddr ¶
ClientAddr handles a client addr.
func ConfigRootFromSnapshot ¶
ConfigRootFromSnapshot derives config root from snapshot.
func DatabaseNow ¶ added in v1.0.63
DatabaseNow returns the current UTC timestamp reported by the database.
func DefaultHeartbeatTimeout ¶ added in v1.0.63
DefaultHeartbeatTimeout returns the default cluster heartbeat timeout.
func DeleteFingerprintConcurrencyCountersTx ¶ added in v1.0.63
func DeleteFingerprintConcurrencyCountersTx(ctx context.Context, tx *gorm.DB, fingerprint string) error
DeleteFingerprintConcurrencyCountersTx removes all limiter state for a closed membership fingerprint.
func DeterministicAPIKeyUUID ¶
DeterministicAPIKeyUUID handles a deterministic api key uuid.
func EnsureOAuthPayloadUUID ¶
EnsureOAuthPayloadUUID validates ensure o auth payload uuid.
func ForwardRefreshToMaster ¶
func ForwardRefreshToMaster(ctx context.Context, master *ClusterNodeRecord, authUUID string, secret string, tlsConfig *tls.Config) ([]byte, error)
ForwardRefreshToMaster converts forward refresh to master.
func HTTPClientTLSConfig ¶ added in v1.0.44
HTTPClientTLSConfig derives an mTLS client config for cluster HTTP calls.
func HashUserSecurityValue ¶ added in v1.0.63
HashUserSecurityValue returns a stable SHA-256 hex digest for tokens and throttle scopes.
func IsAPIKeyConflictError ¶ added in v1.0.63
IsAPIKeyConflictError reports whether an error is an API key uniqueness conflict.
func IsConcurrencySaturated ¶ added in v1.0.63
IsConcurrencySaturated reports whether an admission failed because a configured limit was reached.
func IsUserConflictError ¶ added in v1.0.44
IsUserConflictError reports whether an error is a username uniqueness conflict.
func IsUserEmailConflictError ¶ added in v1.0.63
IsUserEmailConflictError reports whether an error is a verified active-email ownership conflict.
func ModelGroupDetailChannelIDs ¶ added in v1.0.63
func ModelGroupDetailChannelIDs(record *ModelGroupDetailRecord) ([]uint, error)
ModelGroupDetailChannelIDs returns the channel group IDs bound to a model detail.
func NormalizeQuotaWindowValues ¶ added in v1.0.63
func NormalizeQuotaWindowValues(window *QuotaWindow)
NormalizeQuotaWindowValues reconciles quantities, ratios, and derived status.
func OAuthSessionData ¶
func OAuthSessionData(record *OAuthSessionRecord) (map[string]any, error)
OAuthSessionData handles an o auth session data.
func OpenSQLite ¶ added in v1.0.44
OpenSQLite opens a SQLite database.
func ParseChannelRecordID ¶ added in v1.0.44
ParseChannelRecordID parses a positive unsigned record ID.
func ParseModelRecordID ¶ added in v1.0.44
ParseModelRecordID parses a positive unsigned record ID.
func ParseUserRecordID ¶ added in v1.0.44
ParseUserRecordID parses a positive unsigned user record ID.
func QuotaSnapshotVersion ¶ added in v1.0.63
QuotaSnapshotVersion returns the active-collector snapshot version expected for a provider. Provider-specific versions let one collector invalidate its persisted representation without forcing unrelated providers to recollect.
func RecordToAuth ¶
func RecordToAuth(record *AuthRecord) (*coreauth.Auth, error)
RecordToAuth records a to auth.
func RuntimeConfigFromRoot ¶
RuntimeConfigFromRoot derives runtime config from root.
func SafeQuotaRequestID ¶ added in v1.0.63
SafeQuotaRequestID accepts only bounded, non-secret request identifiers.
func SanitizeUsagePayloadSecrets ¶ added in v1.0.63
SanitizeUsagePayloadSecrets removes provider credential material from usage payloads.
func UsagePayloadWithRuntimeMetadata ¶ added in v1.0.63
func UsagePayloadWithRuntimeMetadata(payload string, metadata UsageRuntimeMetadata) (string, error)
UsagePayloadWithRuntimeMetadata fills missing runtime ownership fields without overriding reported values.
func ValidateBillingModelPriceImportPreviewInput ¶ added in v1.0.63
func ValidateBillingModelPriceImportPreviewInput(input BillingModelPriceImportPreviewInput) error
ValidateBillingModelPriceImportPreviewInput validates request-controlled import data before the models.dev catalog is fetched.
func ValidateCredentialConcurrencyLifecycle ¶ added in v1.0.63
func ValidateCredentialConcurrencyLifecycle(nodeHeartbeatTimeout time.Duration, cfg config.CredentialConcurrencyConfig) error
ValidateCredentialConcurrencyLifecycle verifies the lifecycle timing safety invariant.
Types ¶
type APIKeyAdminUpdate ¶ added in v1.0.63
type APIKeyEntry ¶ added in v1.0.44
func APIKeyEntryFromRecord ¶ added in v1.0.44
func APIKeyEntryFromRecord(record *APIKeyRecord) (APIKeyEntry, error)
APIKeyEntryFromRecord converts an API key record to a response entry.
type APIKeyEntryUpdate ¶ added in v1.0.44
type APIKeyRecord ¶
type APIKeyRecord struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement;index:idx_api_key_active_order,priority:2"`
APIKey string `gorm:"column:api_key;not null;uniqueIndex"`
UserID *uint `gorm:"column:user_id;index;index:idx_api_key_user_active,priority:1"`
Channels JSONB `gorm:"column:channels"`
ModelGroups JSONB `gorm:"column:model_groups"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;index:idx_api_key_active_order,priority:1;index:idx_api_key_user_active,priority:2"`
}
func (APIKeyRecord) TableName ¶
func (APIKeyRecord) TableName() string
TableName returns the database table name.
type APIKeySelector ¶ added in v1.0.63
type APIKeyUpsertStats ¶ added in v1.0.44
func (APIKeyUpsertStats) Changed ¶ added in v1.0.44
func (s APIKeyUpsertStats) Changed() bool
Changed reports whether api key rows were mutated.
type APIKeyUserUpdate ¶ added in v1.0.44
type AppLogQuery ¶ added in v1.0.44
type AppLogQueryResult ¶ added in v1.0.44
type AppLogQueryResult struct {
Records []AppLogRecord
Total int64
}
type AppLogRecord ¶ added in v1.0.44
type AppLogRecord struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement;index:idx_log_time_order,priority:2"`
Timestamp time.Time `` /* 195-byte string literal not displayed */
ClientIP string `gorm:"column:client_ip;index:idx_log_client_ip;index:idx_log_client_time,priority:1"`
RequestID string `gorm:"column:request_id;index:idx_log_request_id;index:idx_log_home_request,priority:2"`
HomeIP string `gorm:"column:home_ip;index:idx_log_home_ip;index:idx_log_home_request,priority:1"`
Level string `gorm:"column:level;index:idx_log_level;index:idx_log_level_time,priority:1"`
Line string `gorm:"column:line;type:text;not null"`
CreatedAt time.Time `gorm:"column:created_at;not null;index:idx_log_created_at"`
}
func AppLogRecordFromPayload ¶ added in v1.0.44
func AppLogRecordFromPayload(clientIP string, homeIP string, payload string) (*AppLogRecord, error)
AppLogRecordFromPayload creates an app log record from a CPA payload.
func (AppLogRecord) TableName ¶ added in v1.0.44
func (AppLogRecord) TableName() string
TableName returns the database table name.
type AuthConcurrencyPatchRequest ¶ added in v1.0.63
type AuthConcurrencyPatchRequest struct {
CredentialID string
Auth *coreauth.Auth
AuthChanged bool
PolicyPatch ConcurrencyPolicyPatch
ExpectedPolicyVersion *int64
}
AuthConcurrencyPatchRequest combines an optional auth update with a presence-aware limiter policy update.
type AuthIndex ¶
type AuthIndex struct {
UUID string
ID string
Index string
Provider string
Label string
Prefix string
Status coreauth.Status
Disabled bool
NextRetryAfter time.Time
Quota coreauth.QuotaState
ModelStates map[string]*coreauth.ModelState
BaseURL string
ModelsHash string
Attributes map[string]string
ModelMetadata map[string]any
}
type AuthRecord ¶
type AuthRecord struct {
UUID string `gorm:"column:uuid;primaryKey"`
AuthJSON JSONB `gorm:"column:auth_json;not null"`
Version int64 `gorm:"column:version;not null;default:1"`
ID string `gorm:"column:id;index:idx_auth_active_order,priority:2"`
Index string `gorm:"column:index;index:idx_auth_index_active,priority:1"`
Provider string `gorm:"column:provider"`
Label string `gorm:"column:label"`
Prefix string `gorm:"column:prefix"`
Status coreauth.Status `gorm:"column:status"`
Disabled bool `gorm:"column:disabled"`
BaseURL string `gorm:"column:base_url"`
APIKeyHash string `gorm:"column:api_key_hash"`
CompatName string `gorm:"column:compat_name"`
ProviderKey string `gorm:"column:provider_key"`
ModelsHash string `gorm:"column:models_hash"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
LastRefreshedAt *time.Time `gorm:"column:last_refreshed_at"`
NextRefreshAfter *time.Time `gorm:"column:next_refresh_after"`
NextRetryAfter *time.Time `gorm:"column:next_retry_after"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;index:idx_auth_active_order,priority:1;index:idx_auth_index_active,priority:2"`
}
func AuthToRecord ¶
func AuthToRecord(auth *coreauth.Auth) (*AuthRecord, error)
AuthToRecord converts auth to record.
func (AuthRecord) TableName ¶
func (AuthRecord) TableName() string
TableName returns the database table name.
type BillingBalanceQuery ¶ added in v1.0.44
type BillingBalanceRecord ¶ added in v1.0.44
type BillingBalanceRecord struct {
ID string `gorm:"column:id;primaryKey"`
UserID uint `gorm:"column:user_id;not null;index:idx_billing_balance_user_time,priority:1"`
Type string `gorm:"column:type;not null;index:idx_billing_balance_type_time,priority:1"`
Amount float64 `gorm:"column:amount;not null"`
BalanceBefore float64 `gorm:"column:balance_before;not null"`
BalanceAfter float64 `gorm:"column:balance_after;not null"`
Operator string `gorm:"column:operator;not null"`
Note string `gorm:"column:note;type:text"`
CreatedAt time.Time `` /* 147-byte string literal not displayed */
}
func (BillingBalanceRecord) TableName ¶ added in v1.0.44
func (BillingBalanceRecord) TableName() string
type BillingBalanceResult ¶ added in v1.0.44
type BillingBalanceResult struct {
Records []BillingBalanceRecord
Total int64
}
type BillingBalanceUpdate ¶ added in v1.0.44
type BillingChargeQuery ¶ added in v1.0.44
type BillingChargeRecord ¶ added in v1.0.44
type BillingChargeRecord struct {
ID string `gorm:"column:id;primaryKey"`
UsageID uint `gorm:"column:usage_id;not null;uniqueIndex"`
PayloadHash string `gorm:"column:payload_hash;not null;uniqueIndex"`
UserID *uint `gorm:"column:user_id;index:idx_billing_charge_user_time,priority:1"`
APIKeyID *uint `gorm:"column:api_key_id;index"`
APIKeyLabel string `gorm:"column:api_key_label"`
APIKeyMasked string `gorm:"column:api_key_masked"`
Provider string `gorm:"column:provider;index:idx_billing_charge_provider_model_time,priority:1"`
Model string `gorm:"column:model;index:idx_billing_charge_provider_model_time,priority:2"`
OriginalModel string `gorm:"column:original_model"`
ActualModel string `gorm:"column:actual_model"`
RequestID string `gorm:"column:request_id;index"`
Endpoint string `gorm:"column:endpoint;index"`
InputTokens int64 `gorm:"column:input_tokens;not null;default:0"`
OutputTokens int64 `gorm:"column:output_tokens;not null;default:0"`
CacheTokens int64 `gorm:"column:cache_tokens;not null;default:0"`
Amount float64 `gorm:"column:amount;not null;default:0"`
BalanceBefore float64 `gorm:"column:balance_before;not null;default:0"`
BalanceAfter float64 `gorm:"column:balance_after;not null;default:0"`
MatchedPriceRule string `gorm:"column:matched_price_rule"`
PriceSnapshot JSONB `gorm:"column:price_snapshot;not null"`
RequestSummary string `gorm:"column:request_summary;type:text"`
CreatedAt time.Time `` /* 155-byte string literal not displayed */
}
func (BillingChargeRecord) TableName ¶ added in v1.0.44
func (BillingChargeRecord) TableName() string
type BillingChargeResult ¶ added in v1.0.44
type BillingChargeResult struct {
Records []BillingChargeRecord
Total int64
}
type BillingModelPriceImportAlias ¶ added in v1.0.63
type BillingModelPriceImportApplyInput ¶ added in v1.0.63
type BillingModelPriceImportCatalog ¶ added in v1.0.63
type BillingModelPriceImportCatalog struct {
SourceURL string `json:"source_url"`
Version string `json:"version"`
FetchedAt time.Time `json:"fetched_at"`
Models []BillingModelPriceImportCatalogModel `json:"models"`
}
type BillingModelPriceImportCatalogModel ¶ added in v1.0.63
type BillingModelPriceImportCatalogModel struct {
Provider string `json:"provider"`
Model string `json:"model"`
Name string `json:"name"`
Cost *BillingModelPriceImportCost `json:"cost"`
ContextBands []BillingModelPriceImportContextBand `json:"context_bands"`
InvalidPriceFields []string `json:"invalid_price_fields"`
UnsupportedDimensions []string `json:"unsupported_dimensions"`
ContextBandIssues []string `json:"-"`
}
type BillingModelPriceImportContextBand ¶ added in v1.0.63
type BillingModelPriceImportContextBand struct {
MinInputTokens int64 `json:"min_input_tokens"`
Cost BillingModelPriceImportCost `json:"cost"`
InvalidPriceFields []string `json:"-"`
UnsupportedDimensions []string `json:"-"`
MissingPriceFields []string `json:"-"`
}
type BillingModelPriceImportCost ¶ added in v1.0.63
type BillingModelPriceImportMatchOverride ¶ added in v1.0.63
type BillingModelPriceImportMultiplierRule ¶ added in v1.0.63
type BillingModelPriceImportOperation ¶ added in v1.0.63
type BillingModelPriceImportOperation struct {
OperationID string `json:"operation_id"`
PreviewID string `json:"preview_id"`
Status string `json:"status"`
Atomic bool `json:"atomic"`
AppliedAt time.Time `json:"applied_at"`
Summary BillingModelPriceImportSummary `json:"summary"`
Rows []BillingModelPriceImportOperationRowResult `json:"rows"`
}
type BillingModelPriceImportOperationRecord ¶ added in v1.0.63
type BillingModelPriceImportOperationRecord struct {
ID string `gorm:"column:id;primaryKey"`
PreviewID string `gorm:"column:preview_id;not null;index"`
PreviewRevision string `gorm:"column:preview_revision;not null"`
IdempotencyKey string `gorm:"column:idempotency_key;not null;uniqueIndex"`
RequestHash string `gorm:"column:request_hash;not null"`
SelectionHash string `gorm:"column:selection_hash;not null;index"`
Atomic bool `gorm:"column:atomic;not null"`
Status string `gorm:"column:status;not null"`
AppliedAt time.Time `gorm:"column:applied_at;not null"`
Result JSONB `gorm:"column:result;not null"`
CreatedAt time.Time `gorm:"column:created_at;not null;index"`
}
BillingModelPriceImportOperationRecord persists terminal apply results for idempotent recovery.
func (BillingModelPriceImportOperationRecord) TableName ¶ added in v1.0.63
func (BillingModelPriceImportOperationRecord) TableName() string
type BillingModelPriceImportOperationRowResult ¶ added in v1.0.63
type BillingModelPriceImportOperationRowResult struct {
Key string `json:"key"`
Provider string `json:"provider"`
Model string `json:"model"`
Action string `json:"action"`
Status string `json:"status"`
ResourceID string `json:"resource_id,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}
type BillingModelPriceImportPolicy ¶ added in v1.0.63
type BillingModelPriceImportPolicy struct {
OverwriteMode string `json:"overwrite_mode"`
DefaultMultiplier float64 `json:"default_multiplier"`
MultiplierRules []BillingModelPriceImportMultiplierRule `json:"multiplier_rules"`
Aliases []BillingModelPriceImportAlias `json:"aliases"`
RowMultipliers map[string]float64 `json:"row_multipliers"`
IncludeZeroCost bool `json:"include_zero_cost"`
}
type BillingModelPriceImportPreview ¶ added in v1.0.63
type BillingModelPriceImportPreview struct {
PreviewID string `json:"preview_id"`
PreviewRevision string `json:"preview_revision"`
Source string `json:"source"`
SourceURL string `json:"source_url"`
SourceVersion string `json:"source_version"`
SourceFetchedAt time.Time `json:"source_fetched_at"`
SourceModelCount int `json:"source_model_count"`
GeneratedAt time.Time `json:"generated_at"`
ExpiresAt time.Time `json:"expires_at"`
Atomic bool `json:"atomic"`
Rows []BillingModelPriceImportPreviewRow `json:"rows"`
Summary BillingModelPriceImportSummary `json:"summary"`
}
type BillingModelPriceImportPreviewInput ¶ added in v1.0.63
type BillingModelPriceImportPreviewInput struct {
Source string `json:"source"`
Targets []BillingModelPriceImportTarget `json:"targets"`
Policy BillingModelPriceImportPolicy `json:"policy"`
MatchOverrides []BillingModelPriceImportMatchOverride `json:"match_overrides"`
}
type BillingModelPriceImportPreviewRecord ¶ added in v1.0.63
type BillingModelPriceImportPreviewRecord struct {
ID string `gorm:"column:id;primaryKey"`
Revision string `gorm:"column:revision;not null;uniqueIndex"`
Source string `gorm:"column:source;not null"`
SourceURL string `gorm:"column:source_url;not null"`
SourceVersion string `gorm:"column:source_version;not null"`
SourceFetchedAt time.Time `gorm:"column:source_fetched_at;not null"`
SourceModelCount int `gorm:"column:source_model_count;not null"`
Atomic bool `gorm:"column:atomic;not null;default:true"`
GeneratedAt time.Time `gorm:"column:generated_at;not null"`
ExpiresAt time.Time `gorm:"column:expires_at;not null;index"`
Payload JSONB `gorm:"column:payload;not null"`
CreatedAt time.Time `gorm:"column:created_at;not null;index"`
}
BillingModelPriceImportPreviewRecord stores a server-generated import plan.
func (BillingModelPriceImportPreviewRecord) TableName ¶ added in v1.0.63
func (BillingModelPriceImportPreviewRecord) TableName() string
type BillingModelPriceImportPreviewRow ¶ added in v1.0.63
type BillingModelPriceImportPreviewRow struct {
RowKey string `json:"row_key"`
Provider string `json:"provider"`
Model string `json:"model"`
ServiceTier string `json:"service_tier"`
MinInputTokens int64 `json:"min_input_tokens"`
Label string `json:"label"`
Status string `json:"status"`
Action string `json:"action"`
Applicable bool `json:"applicable"`
SelectedDefault bool `json:"selected_by_default"`
MatchedProvider string `json:"matched_provider,omitempty"`
MatchedModel string `json:"matched_model,omitempty"`
MatchedName string `json:"matched_name,omitempty"`
Official *BillingModelPriceImportCost `json:"official,omitempty"`
Multiplier float64 `json:"multiplier"`
Final *BillingModelPriceImportCost `json:"final,omitempty"`
WriteRule *BillingModelPriceImportWriteRule `json:"write_rule,omitempty"`
ExistingRule *BillingModelPriceImportRuleSnapshot `json:"existing_rule,omitempty"`
Reasons []BillingModelPriceImportReason `json:"reasons"`
}
type BillingModelPriceImportReason ¶ added in v1.0.63
type BillingModelPriceImportRuleSnapshot ¶ added in v1.0.63
type BillingModelPriceImportRuleSnapshot struct {
ID string `json:"id"`
Provider string `json:"provider"`
Model string `json:"model"`
ServiceTier string `json:"service_tier"`
MinInputTokens int64 `json:"min_input_tokens"`
InputPricePerMillion float64 `json:"input_price_per_million"`
OutputPricePerMillion float64 `json:"output_price_per_million"`
CacheReadPricePerMillion float64 `json:"cache_read_price_per_million"`
CacheWritePricePerMillion float64 `json:"cache_write_price_per_million"`
RequestPrice float64 `json:"request_price"`
Source string `json:"source"`
Enabled bool `json:"enabled"`
Note string `json:"note"`
Revision string `json:"revision"`
}
type BillingModelPriceImportSummary ¶ added in v1.0.63
type BillingModelPriceImportTarget ¶ added in v1.0.63
type BillingModelPriceImportWriteRule ¶ added in v1.0.63
type BillingModelPricePatch ¶ added in v1.0.44
type BillingModelPricePatch struct {
Provider *string
Model *string
ServiceTier *string
MinInputTokens *int64
InputPricePerMillion *float64
OutputPricePerMillion *float64
CacheReadPricePerMillion *float64
CacheWritePricePerMillion *float64
RequestPrice *float64
Source *string
Enabled *bool
Note *string
}
type BillingModelPriceQuery ¶ added in v1.0.44
type BillingModelPriceRecord ¶ added in v1.0.44
type BillingModelPriceRecord struct {
ID string `gorm:"column:id;primaryKey"`
Provider string `gorm:"column:provider;not null;index:idx_billing_model_price_lookup,priority:1"`
Model string `gorm:"column:model;not null;index:idx_billing_model_price_lookup,priority:2"`
ServiceTier string `gorm:"column:service_tier;not null;default:*"`
MinInputTokens int64 `gorm:"column:min_input_tokens;not null;default:0"`
InputPricePerMillion float64 `gorm:"column:input_price_per_million;not null;default:0"`
OutputPricePerMillion float64 `gorm:"column:output_price_per_million;not null;default:0"`
CacheReadPricePerMillion float64 `gorm:"column:cache_read_price_per_million;not null;default:0"`
CacheWritePricePerMillion float64 `gorm:"column:cache_write_price_per_million;not null;default:0"`
RequestPrice float64 `gorm:"column:request_price;not null;default:0"`
Source string `gorm:"column:source;not null;default:manual"`
Enabled bool `gorm:"column:enabled;not null;index:idx_billing_model_price_enabled"`
Note string `gorm:"column:note;type:text"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
Revision int64 `gorm:"column:revision;not null;default:1"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index"`
}
func (BillingModelPriceRecord) TableName ¶ added in v1.0.44
func (BillingModelPriceRecord) TableName() string
type BillingModelPriceUpdate ¶ added in v1.0.44
type BillingOverview ¶ added in v1.0.44
type BillingOverview struct {
Range BillingRange
TotalChargeAmount float64
TotalRechargeAmount float64
TotalDeductAmount float64
TotalBalance float64
RequestCount int64
InputTokens int64
OutputTokens int64
CacheTokens int64
ActiveUserCount int64
DailyTrend []BillingTrendPoint
TopUsers []BillingTopItem
TopModels []BillingTopItem
TopProviders []BillingTopItem
}
type BillingOverviewQuery ¶ added in v1.0.44
type BillingPriceSnapshot ¶ added in v1.0.44
type BillingPriceSnapshot struct {
Provider string `json:"provider"`
Model string `json:"model"`
InputPricePerMillion float64 `json:"input_price_per_million"`
OutputPricePerMillion float64 `json:"output_price_per_million"`
CacheReadPricePerMillion float64 `json:"cache_read_price_per_million"`
CacheWritePricePerMillion float64 `json:"cache_write_price_per_million"`
RequestPrice float64 `json:"request_price"`
MatchedServiceTier string `json:"matched_service_tier"`
MinInputTokens int64 `json:"min_input_tokens"`
RequestedServiceTier string `json:"requested_service_tier"`
ResponseServiceTier string `json:"response_service_tier,omitempty"`
ServiceTierSource string `json:"service_tier_source"`
EffectiveServiceTier string `json:"effective_service_tier"`
ResponseTierFallback bool `json:"response_tier_fallback"`
}
type BillingRange ¶ added in v1.0.44
type BillingSettings ¶ added in v1.0.63
type BillingSettingsPatch ¶ added in v1.0.63
type BillingTierDiagnostics ¶ added in v1.0.63
type BillingTierDiagnostics struct {
Supported bool `json:"supported"`
WindowStart *time.Time `json:"window_start"`
WindowEnd *time.Time `json:"window_end"`
EligibleRequests int64 `json:"eligible_requests"`
ResponseTierRequests int64 `json:"response_tier_requests"`
FallbackRequests int64 `json:"fallback_requests"`
LastResponseTierAt *time.Time `json:"last_response_tier_at,omitempty"`
}
type BillingTopItem ¶ added in v1.0.44
type BillingTrendPoint ¶ added in v1.0.44
type CPAInFlightSnapshotAttemptRecord ¶ added in v1.0.63
type CPAInFlightSnapshotAttemptRecord struct {
CertificateFingerprint string `gorm:"column:certificate_fingerprint;primaryKey;size:64"`
MembershipConnectedAt time.Time `gorm:"column:membership_connected_at;primaryKey"`
HighestSeenRevision int64 `gorm:"column:highest_seen_revision;not null"`
State string `gorm:"column:state;size:16;not null;check:state IN ('staging','complete','overflow','rejected')"`
ObservedAt time.Time `gorm:"column:observed_at;not null"`
BarrierRevision int64 `gorm:"column:barrier_revision;not null"`
PartCount int `gorm:"column:part_count;not null"`
ReceivedPartCount int `gorm:"column:received_part_count;not null"`
EncodedBytes int64 `gorm:"column:encoded_bytes;not null"`
AggregateGroupCount int `gorm:"column:aggregate_group_count;not null"`
DetailsTruncated bool `gorm:"column:details_truncated;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null;index;autoUpdateTime:false"`
}
func (CPAInFlightSnapshotAttemptRecord) TableName ¶ added in v1.0.63
func (CPAInFlightSnapshotAttemptRecord) TableName() string
type CPAInFlightSnapshotPartRecord ¶ added in v1.0.63
type CPAInFlightSnapshotPartRecord struct {
CertificateFingerprint string `gorm:"column:certificate_fingerprint;primaryKey;size:64"`
MembershipConnectedAt time.Time `gorm:"column:membership_connected_at;primaryKey"`
Revision int64 `gorm:"column:revision;primaryKey"`
PartIndex int `gorm:"column:part_index;primaryKey"`
Payload []byte `gorm:"column:payload;not null"`
EncodedBytes int `gorm:"column:encoded_bytes;not null"`
CreatedAt time.Time `gorm:"column:created_at;not null;autoCreateTime:false"`
UpdatedAt time.Time `gorm:"column:updated_at;not null;index;autoUpdateTime:false"`
}
func (CPAInFlightSnapshotPartRecord) TableName ¶ added in v1.0.63
func (CPAInFlightSnapshotPartRecord) TableName() string
type CPAInFlightSnapshotRecord ¶ added in v1.0.63
type CPAInFlightSnapshotRecord struct {
CertificateFingerprint string `gorm:"column:certificate_fingerprint;primaryKey;size:64"`
NodeID string `gorm:"column:node_id;size:256;not null"`
MembershipConnectedAt time.Time `gorm:"column:membership_connected_at;not null;index"`
Revision int64 `gorm:"column:revision;not null"`
ObservedAt time.Time `gorm:"column:observed_at;not null"`
BarrierRevision int64 `gorm:"column:barrier_revision;not null"`
DetailsTruncated bool `gorm:"column:details_truncated;not null"`
Payload JSONB `gorm:"column:payload;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null;index;autoUpdateTime:false"`
}
func (CPAInFlightSnapshotRecord) TableName ¶ added in v1.0.63
func (CPAInFlightSnapshotRecord) TableName() string
type CPANodeMembershipRecord ¶ added in v1.0.63
type CPANodeMembershipRecord struct {
CertificateFingerprint string `gorm:"column:certificate_fingerprint;primaryKey"`
NodeID string `gorm:"column:node_id;not null"`
HomeIP string `gorm:"column:home_ip;not null"`
HomePort int `gorm:"column:home_port;not null"`
HomeStartedAt time.Time `gorm:"column:home_started_at;not null"`
ProtocolVersion int `gorm:"column:protocol_version;not null"`
State string `gorm:"column:state;not null;index"`
CancelRevision int64 `gorm:"column:cancel_revision;not null"`
CancelStartedAt *time.Time `gorm:"column:cancel_started_at"`
ExpectedQuiescenceCount int64 `gorm:"column:expected_quiescence_count;not null"`
ConnectedAt time.Time `gorm:"column:connected_at;not null"`
LifecycleConfigRevision int64 `gorm:"column:lifecycle_config_revision;not null"`
CPAHeartbeatTimeout time.Duration `gorm:"column:cpa_heartbeat_timeout;not null"`
CPACancelBound time.Duration `gorm:"column:cpa_cancel_bound;not null"`
ReclaimGrace time.Duration `gorm:"column:reclaim_grace;not null"`
LastSeenAt time.Time `gorm:"column:last_seen_at;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null"`
}
CPANodeMembershipRecord contains only the membership fields needed by the lifecycle gate.
func (CPANodeMembershipRecord) TableName ¶ added in v1.0.63
func (CPANodeMembershipRecord) TableName() string
type CPANodeParticipationRecord ¶ added in v1.0.63
type CPANodeParticipationRecord struct {
CertificateFingerprint string `gorm:"column:certificate_fingerprint;primaryKey"`
MembershipConnectedAt time.Time `gorm:"column:membership_connected_at;primaryKey"`
HomeIP string `gorm:"column:home_ip;primaryKey"`
HomePort int `gorm:"column:home_port;primaryKey"`
HomeStartedAt time.Time `gorm:"column:home_started_at;primaryKey"`
CreatedAt time.Time `gorm:"column:created_at;not null"`
}
CPANodeParticipationRecord identifies a Home's connection to a membership lifetime.
func (CPANodeParticipationRecord) TableName ¶ added in v1.0.63
func (CPANodeParticipationRecord) TableName() string
type CPANodeQuiescenceRecord ¶ added in v1.0.63
type CPANodeQuiescenceRecord struct {
CertificateFingerprint string `gorm:"column:certificate_fingerprint;primaryKey"`
MembershipConnectedAt time.Time `gorm:"column:membership_connected_at;primaryKey"`
CancelRevision int64 `gorm:"column:cancel_revision;primaryKey"`
HomeIP string `gorm:"column:home_ip;primaryKey"`
HomePort int `gorm:"column:home_port;primaryKey"`
HomeStartedAt time.Time `gorm:"column:home_started_at;primaryKey"`
Status string `gorm:"column:status;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null"`
}
CPANodeQuiescenceRecord records one Home incarnation's fence acknowledgement.
func (CPANodeQuiescenceRecord) TableName ¶ added in v1.0.63
func (CPANodeQuiescenceRecord) TableName() string
type CPANodeRecord ¶ added in v1.0.63
type CPANodeRecord struct {
HomeIP string `gorm:"column:home_ip;primaryKey;index:idx_cpa_node_home_live,priority:1;index:idx_cpa_node_live,priority:3"`
HomePort int `gorm:"column:home_port;primaryKey;index:idx_cpa_node_home_live,priority:2;index:idx_cpa_node_live,priority:4"`
HomeStartedAt time.Time `gorm:"column:home_started_at;primaryKey"`
NodeKey string `gorm:"column:node_key;primaryKey;size:256"`
NodeID string `gorm:"column:node_id;index"`
ClientIP string `gorm:"column:client_ip;index"`
ClientCount int `gorm:"column:client_count"`
CertificateFingerprint string `gorm:"column:certificate_fingerprint"`
OpenConnections int `gorm:"column:open_connections"`
ActiveHandlers int `gorm:"column:active_handlers"`
LatestCancelRevision int64 `gorm:"column:latest_cancel_revision"`
ConnectedAt time.Time `gorm:"column:connected_at"`
LastSeenAt time.Time `gorm:"column:last_seen_at;index:idx_cpa_node_home_live,priority:3;index:idx_cpa_node_live,priority:1"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (CPANodeRecord) TableName ¶ added in v1.0.63
func (CPANodeRecord) TableName() string
TableName returns the database table name.
type CertificateRecord ¶ added in v1.0.44
type CertificateRecord struct {
ID string `gorm:"column:id;primaryKey;index:idx_certificate_ca_order,priority:3"`
ClusterID string `gorm:"column:cluster_id;index"`
CertificatePEM string `gorm:"column:certificate_pem;type:text"`
CertificateFingerprint string `gorm:"column:certificate_fingerprint;index;index:idx_certificate_peer_lookup,priority:1"`
PrivateKeyPEM string `gorm:"column:private_key_pem;type:text"`
CSRPEM string `gorm:"column:csr_pem;type:text"`
IP string `gorm:"column:ip;index:idx_certificate_server_ip,priority:2"`
CAFingerprint string `gorm:"column:ca_fingerprint"`
EnrollmentSecretHash string `gorm:"column:enrollment_secret_hash"`
IsCA bool `gorm:"column:is_ca;index;index:idx_certificate_ca_order,priority:1"`
IsServer bool `gorm:"column:is_server;index:idx_certificate_server_ip,priority:1;index:idx_certificate_peer_lookup,priority:3"`
IsClient bool `gorm:"column:is_client;index;index:idx_certificate_peer_lookup,priority:2"`
SerialNumber string `gorm:"column:serial_number"`
NotBefore time.Time `gorm:"column:not_before"`
NotAfter time.Time `gorm:"column:not_after"`
CreatedAt time.Time `gorm:"column:created_at;index:idx_certificate_ca_order,priority:2"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (CertificateRecord) TableName ¶ added in v1.0.44
func (CertificateRecord) TableName() string
TableName returns the database table name.
type ChannelGroupDetailFilter ¶ added in v1.0.44
type ChannelGroupDetailRecord ¶ added in v1.0.44
type ChannelGroupDetailRecord struct {
ID uint `` /* 162-byte string literal not displayed */
ChannelGroupID uint `` /* 160-byte string literal not displayed */
AuthID string `gorm:"column:auth_id;not null;index:idx_channel_group_detail_auth_active_order,priority:1"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
DeletedAt gorm.DeletedAt `` /* 151-byte string literal not displayed */
}
func (ChannelGroupDetailRecord) TableName ¶ added in v1.0.44
func (ChannelGroupDetailRecord) TableName() string
TableName returns the database table name.
type ChannelGroupDetailUpdate ¶ added in v1.0.44
type ChannelGroupRecord ¶ added in v1.0.44
type ChannelGroupRecord struct {
ID uint `` /* 138-byte string literal not displayed */
ChannelName string `gorm:"column:channel_name;not null"`
Disabled bool `gorm:"column:disabled;not null;default:false;index:idx_channel_group_enabled_order,priority:2"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
DeletedAt gorm.DeletedAt `` /* 127-byte string literal not displayed */
}
func (ChannelGroupRecord) TableName ¶ added in v1.0.44
func (ChannelGroupRecord) TableName() string
TableName returns the database table name.
type ChannelGroupUpdate ¶ added in v1.0.44
type ClusterEventRecord ¶
type ClusterEventRecord struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement;index:idx_cluster_events_scope_id,priority:2"`
Scope string `gorm:"column:scope;index:idx_cluster_events_scope_id,priority:1"`
Op string `gorm:"column:op"`
EntityUUID string `gorm:"column:entity_uuid"`
Version int64 `gorm:"column:version"`
CreatedAt time.Time `gorm:"column:created_at"`
}
func (ClusterEventRecord) TableName ¶
func (ClusterEventRecord) TableName() string
TableName returns the database table name.
type ClusterNodeRecord ¶
type ClusterNodeRecord struct {
IP string `` /* 282-byte string literal not displayed */
Port int `` /* 284-byte string literal not displayed */
SecretHash string `gorm:"column:secret_hash;index:idx_cluster_auth_lookup,priority:2;index:idx_cluster_auth_live_first,priority:2"`
IsMaster bool `gorm:"column:is_master;index:idx_cluster_master_nodes,priority:1;index:idx_cluster_master_current,priority:1"`
ClientCount int `gorm:"column:client_count;index:idx_cluster_live_schedule,priority:1"`
StartedAt time.Time `` /* 279-byte string literal not displayed */
LastSeenAt time.Time `` /* 291-byte string literal not displayed */
}
func (ClusterNodeRecord) TableName ¶
func (ClusterNodeRecord) TableName() string
TableName returns the database table name.
type ConcurrencyActivationGateRecord ¶ added in v1.0.63
type ConcurrencyActivationGateRecord struct {
ID int `gorm:"column:id;primaryKey"`
ActivePolicyCount int64 `gorm:"column:active_policy_count;not null"`
}
ConcurrencyActivationGateRecord serializes legacy admission and policy activation.
func (ConcurrencyActivationGateRecord) TableName ¶ added in v1.0.63
func (ConcurrencyActivationGateRecord) TableName() string
type ConcurrencyAdmissionError ¶ added in v1.0.63
type ConcurrencyAdmissionError struct {
Type string
RetryAfterMS int64
// contains filtered or unexported fields
}
ConcurrencyAdmissionError is a typed admission failure suitable for protocol translation.
func (*ConcurrencyAdmissionError) ConcurrencyType ¶ added in v1.0.63
func (e *ConcurrencyAdmissionError) ConcurrencyType() string
ConcurrencyType returns the stable protocol error type without exposing its cause.
func (*ConcurrencyAdmissionError) Error ¶ added in v1.0.63
func (e *ConcurrencyAdmissionError) Error() string
func (*ConcurrencyAdmissionError) Unwrap ¶ added in v1.0.63
func (e *ConcurrencyAdmissionError) Unwrap() error
type ConcurrencyAdmissionRequest ¶ added in v1.0.63
type ConcurrencyAdmissionRequest struct {
CredentialID string
Model string
Lifetime ConnectionLifetime
ProtocolVersion int
}
ConcurrencyAdmissionRequest identifies one credential request that may need concurrency accounting.
type ConcurrencyAdmissionResult ¶ added in v1.0.63
ConcurrencyAdmissionResult describes the canonical credential and model admitted by the limiter.
type ConcurrencyCredentialReferenceChecker ¶ added in v1.0.63
type ConcurrencyCredentialReferenceChecker struct{}
ConcurrencyCredentialReferenceChecker prevents replacement of credentials still used by limiter state.
func (ConcurrencyCredentialReferenceChecker) HasCredentialReferences ¶ added in v1.0.63
func (ConcurrencyCredentialReferenceChecker) HasCredentialReferences(ctx context.Context, tx *gorm.DB, credentialID string) (bool, error)
HasCredentialReferences reports whether a policy or dynamic counter still uses a credential.
type ConcurrencyObservationBarrierRecord ¶ added in v1.0.63
type ConcurrencyObservationBarrierRecord struct {
ID int `gorm:"column:id;primaryKey"`
Revision int64 `gorm:"column:revision;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null"`
}
ConcurrencyObservationBarrierRecord keeps the global observation barrier revision.
func (ConcurrencyObservationBarrierRecord) TableName ¶ added in v1.0.63
func (ConcurrencyObservationBarrierRecord) TableName() string
type ConcurrencyPolicyPatch ¶ added in v1.0.63
type ConcurrencyPolicyPatch struct {
MaxInFlight OptionalLimit `json:"max_in_flight"`
MaxInFlightByModel OptionalModelLimitMap `json:"max_in_flight_by_model"`
}
ConcurrencyPolicyPatch is a presence-aware replacement patch for a credential policy.
type ConcurrencyReleaseRequest ¶ added in v1.0.63
type ConcurrencyReleaseRequest struct {
CredentialID string
Model string
ReleaseSeq int64
Lifetime ConnectionLifetime
}
ConcurrencyReleaseRequest identifies a cumulative release for one credential and model.
type Config ¶
type Config struct {
PGSQL PGSQLConfig `yaml:"pgsql"`
SQLite SQLiteConfig `yaml:"sqlite"`
Node NodeConfig `yaml:"node"`
}
func LoadConfigOptional ¶
LoadConfigOptional loads a config optional.
func (*Config) DatabaseBackend ¶ added in v1.0.44
func (c *Config) DatabaseBackend() DatabaseBackend
DatabaseBackend returns the selected database backend.
type ConfigRecord ¶
type ConfigRecord struct {
Key string `gorm:"column:key;primaryKey"`
Value JSONB `gorm:"column:value;not null"`
Version int64 `gorm:"column:version;not null;default:1"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (ConfigRecord) TableName ¶
func (ConfigRecord) TableName() string
TableName returns the database table name.
type ConnectionLifetime ¶ added in v1.0.63
type ConnectionLifetime struct {
Fingerprint string
ConnectedAt time.Time
Home HomeIncarnationID
Controlled bool
Subscription bool
}
ConnectionLifetime identifies the membership lifetime associated with a connection.
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
func NewCoordinator ¶
func NewCoordinator(repo *Repository, node NodeIdentity, opts CoordinatorOptions) *Coordinator
NewCoordinator creates a new coordinator.
func (*Coordinator) CurrentMaster ¶
func (c *Coordinator) CurrentMaster(ctx context.Context) (*ClusterNodeRecord, error)
CurrentMaster returns a current master.
func (*Coordinator) HomeIncarnation ¶ added in v1.0.63
func (c *Coordinator) HomeIncarnation() (HomeIncarnationID, bool)
HomeIncarnation returns the initialized Home process identity.
func (*Coordinator) Initialize ¶ added in v1.0.63
func (c *Coordinator) Initialize(ctx context.Context) error
Initialize persists this Home process incarnation before listeners accept traffic.
func (*Coordinator) IsMaster ¶
func (c *Coordinator) IsMaster() bool
IsMaster reports whether is master.
func (*Coordinator) NodeSecret ¶
func (c *Coordinator) NodeSecret() string
NodeSecret handles a node secret.
func (*Coordinator) RetireHomeIncarnation ¶ added in v1.0.63
func (c *Coordinator) RetireHomeIncarnation(ctx context.Context) error
RetireHomeIncarnation retires the initialized Home process incarnation.
func (*Coordinator) SetOnMasterChanged ¶
func (c *Coordinator) SetOnMasterChanged(callback func(bool))
SetOnMasterChanged sets an on master changed.
func (*Coordinator) Start ¶
func (c *Coordinator) Start(ctx context.Context) error
Start starts subsequent coordinator heartbeats after initialization.
func (*Coordinator) UpdateClientCount ¶
func (c *Coordinator) UpdateClientCount(ctx context.Context, clientCount int) error
UpdateClientCount stores the current active CPA client count for this node.
type CoordinatorOptions ¶
type CredentialConcurrencyCounterRecord ¶ added in v1.0.63
type CredentialConcurrencyCounterRecord struct {
CredentialID string `gorm:"column:credential_id;primaryKey;size:128"`
Model string `gorm:"column:model;primaryKey;size:256"`
CertificateFingerprint string `gorm:"column:certificate_fingerprint;primaryKey;size:64"`
ActiveCount int64 `gorm:"column:active_count;not null"`
LastReleaseSeq int64 `gorm:"column:last_release_seq;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null"`
}
CredentialConcurrencyCounterRecord is reserved for aggregate limiter counters.
func (CredentialConcurrencyCounterRecord) TableName ¶ added in v1.0.63
func (CredentialConcurrencyCounterRecord) TableName() string
type CredentialConcurrencyExchangePolicy ¶ added in v1.0.63
type CredentialConcurrencyExchangePolicy struct {
MaxInFlight *int64 `yaml:"max-in-flight,omitempty" json:"max-in-flight,omitempty"`
MaxInFlightByModel map[string]int64 `yaml:"max-in-flight-by-model,omitempty" json:"max-in-flight-by-model,omitempty"`
}
CredentialConcurrencyExchangePolicy is the portable policy representation for one credential.
type CredentialConcurrencyModelPolicyRecord ¶ added in v1.0.63
type CredentialConcurrencyModelPolicyRecord struct {
CredentialID string `gorm:"column:credential_id;primaryKey;size:128"`
Model string `gorm:"column:model;primaryKey;size:256"`
MaxInFlight int64 `gorm:"column:max_in_flight;not null"`
}
CredentialConcurrencyModelPolicyRecord stores a credential's model concurrency policy.
func (CredentialConcurrencyModelPolicyRecord) TableName ¶ added in v1.0.63
func (CredentialConcurrencyModelPolicyRecord) TableName() string
type CredentialConcurrencyModelState ¶ added in v1.0.63
type CredentialConcurrencyModelState struct {
Model string
MaxInFlight int64
AdmittedInFlight int64
}
CredentialConcurrencyModelState is the authoritative policy and admitted count for one model.
type CredentialConcurrencyPolicy ¶ added in v1.0.63
type CredentialConcurrencyPolicy struct {
CredentialID string `json:"credential_id"`
MaxInFlight *int64 `json:"max_in_flight"`
MaxInFlightByModel map[string]int64 `json:"max_in_flight_by_model"`
Version int64 `json:"version"`
EffectiveAt time.Time `json:"effective_at"`
ObservationBarrierRevision int64 `json:"observation_barrier_revision"`
}
CredentialConcurrencyPolicy is the authoritative stored policy for one credential.
type CredentialConcurrencyPolicyRecord ¶ added in v1.0.63
type CredentialConcurrencyPolicyRecord struct {
CredentialID string `gorm:"column:credential_id;primaryKey;size:128"`
MaxInFlight *int64 `gorm:"column:max_in_flight"`
Version int64 `gorm:"column:version;not null"`
EffectiveAt time.Time `gorm:"column:effective_at;not null"`
ObservationBarrierRevision int64 `gorm:"column:observation_barrier_revision;not null;default:0"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
CredentialConcurrencyPolicyRecord stores a credential's total concurrency policy.
func (CredentialConcurrencyPolicyRecord) TableName ¶ added in v1.0.63
func (CredentialConcurrencyPolicyRecord) TableName() string
type CredentialConcurrencyState ¶ added in v1.0.63
type CredentialConcurrencyState struct {
CredentialID string
MaxInFlight *int64
AdmittedInFlight int64
PolicyVersion int64
EffectiveAt time.Time
ObservationBarrier int64
Models []CredentialConcurrencyModelState
}
CredentialConcurrencyState is the authoritative policy and admitted-count state for one credential.
type CredentialConfigCounts ¶
type CredentialConfigCounts struct {
GeminiKeys int
VertexKeys int
CodexKeys int
XAIKeys int
ClaudeKeys int
OpenAICompatibility int
}
CredentialConfigCounts reports how many auth-backed config entries were restored.
func ApplyCredentialConfigToRoot ¶
func ApplyCredentialConfigToRoot(root map[string]any, auths []*coreauth.Auth) CredentialConfigCounts
ApplyCredentialConfigToRoot restores auth-backed config keys into a config root.
type CredentialReferenceChecker ¶ added in v1.0.63
type CredentialReferenceChecker interface {
HasCredentialReferences(context.Context, *gorm.DB, string) (bool, error)
}
CredentialReferenceChecker reports whether another store still references a credential.
type DatabaseBackend ¶ added in v1.0.44
type DatabaseBackend string
const ( DatabaseBackendPostgres DatabaseBackend = "postgres" DatabaseBackendSQLite DatabaseBackend = "sqlite" )
type DatabaseSnapshotExportOptions ¶ added in v1.0.63
type DatabaseSnapshotExportOptions struct {
Path string
HomeVersion string
HomeCommit string
Progress func(DatabaseSnapshotProgress)
}
DatabaseSnapshotExportOptions configures a logical snapshot export.
type DatabaseSnapshotImportResult ¶ added in v1.0.63
type DatabaseSnapshotImportResult struct {
Tables []DatabaseSnapshotImportTableResult
}
DatabaseSnapshotImportResult reports all table-level import counts.
func ImportDatabaseSnapshot ¶ added in v1.0.63
func ImportDatabaseSnapshot(ctx context.Context, db *gorm.DB, snapshot *ValidatedDatabaseSnapshot, progress func(DatabaseSnapshotProgress)) (DatabaseSnapshotImportResult, error)
ImportDatabaseSnapshot restores persistent business tables into an empty target database. Runtime-only tables remain untouched and are reported as skipped.
type DatabaseSnapshotImportTableResult ¶ added in v1.0.63
DatabaseSnapshotImportTableResult reports one imported or skipped table.
type DatabaseSnapshotManifest ¶ added in v1.0.63
type DatabaseSnapshotManifest struct {
Format string `json:"format"`
FormatVersion int `json:"format_version"`
CreatedAt time.Time `json:"created_at"`
HomeVersion string `json:"home_version"`
HomeCommit string `json:"home_commit"`
SourceBackend DatabaseBackend `json:"source_backend"`
Tables []DatabaseSnapshotManifestTable `json:"tables"`
}
DatabaseSnapshotManifest describes one portable Home database snapshot.
func ExportDatabaseSnapshot ¶ added in v1.0.63
func ExportDatabaseSnapshot(ctx context.Context, db *gorm.DB, opts DatabaseSnapshotExportOptions) (DatabaseSnapshotManifest, error)
ExportDatabaseSnapshot writes a versioned portable database snapshot.
type DatabaseSnapshotManifestTable ¶ added in v1.0.63
type DatabaseSnapshotManifestTable struct {
Name string `json:"name"`
Rows int64 `json:"rows"`
SHA256 string `json:"sha256"`
Restore bool `json:"restore"`
}
DatabaseSnapshotManifestTable describes one JSONL table entry.
type DatabaseSnapshotProgress ¶ added in v1.0.63
DatabaseSnapshotProgress describes a completed snapshot table stage.
type EventWatcher ¶
type EventWatcher struct {
// contains filtered or unexported fields
}
func NewEventWatcher ¶
func NewEventWatcher(repo *Repository, pollInterval time.Duration, onEvent func(context.Context, ClusterEventRecord) error) *EventWatcher
NewEventWatcher creates a new event watcher.
func NewEventWatcherFrom ¶
func NewEventWatcherFrom(repo *Repository, pollInterval time.Duration, lastSeenID int64, onEvent func(context.Context, ClusterEventRecord) error) *EventWatcher
NewEventWatcherFrom creates a new event watcher from.
type ExportOptions ¶ added in v1.0.44
type ExportStats ¶ added in v1.0.44
func ExportLocalState ¶ added in v1.0.44
func ExportLocalState(ctx context.Context, opts ExportOptions) (ExportStats, error)
ExportLocalState exports repository config and auth files into a local directory.
type HomeIncarnationID ¶ added in v1.0.63
HomeIncarnationID identifies one append-only Home process incarnation.
type HomeProcessIncarnationRecord ¶ added in v1.0.63
type HomeProcessIncarnationRecord struct {
HomeIP string `gorm:"column:home_ip;primaryKey"`
HomePort int `gorm:"column:home_port;primaryKey"`
StartedAt time.Time `gorm:"column:started_at;primaryKey"`
LastSeenAt time.Time `gorm:"column:last_seen_at;not null;index"`
State string `gorm:"column:state;not null;index"`
FencedAt *time.Time `gorm:"column:fenced_at"`
FenceReason string `gorm:"column:fence_reason"`
Capabilities JSONB `gorm:"column:capabilities;not null"`
}
HomeProcessIncarnationRecord stores an append-only Home process incarnation.
func (HomeProcessIncarnationRecord) TableName ¶ added in v1.0.63
func (HomeProcessIncarnationRecord) TableName() string
type ImportOptions ¶ added in v1.0.44
type ImportStats ¶ added in v1.0.44
type ImportStats struct {
Created int
Updated int
Unchanged int
Restored int
Overwritten int
Skipped int
}
func ImportLocalState ¶ added in v1.0.44
func ImportLocalState(ctx context.Context, opts ImportOptions) (ImportStats, error)
ImportLocalState imports config.yaml and auth-dir credentials into the repository.
type InFlightAccountedStatus ¶ added in v1.0.63
type InFlightAccountedStatus string
type InFlightAggregate ¶ added in v1.0.63
type InFlightAggregate struct {
CredentialID string `json:"credential_id"`
Model string `json:"model"`
Status InFlightAccountedStatus `json:"status"`
Count int64 `json:"count"`
}
type InFlightFrameKind ¶ added in v1.0.63
type InFlightFrameKind string
type InFlightIngestIdentity ¶ added in v1.0.63
type InFlightIngestIdentity struct {
CertificateFingerprint string
NodeID string
MembershipConnectedAt time.Time
}
InFlightIngestIdentity identifies the active CPA membership submitting a frame.
type InFlightIngestResult ¶ added in v1.0.63
InFlightIngestResult reports the outcome of an in-flight frame submission.
type InFlightLimits ¶ added in v1.0.63
type InFlightLimits struct {
MaxPartBytes int
MaxPartCount int
MaxRevisionBytes int
MaxAggregateGroups int
MaxDetails int
MaxStringBytes int
}
InFlightLimits bounds in-flight snapshot ingestion.
func DefaultInFlightLimits ¶ added in v1.0.63
func DefaultInFlightLimits() InFlightLimits
DefaultInFlightLimits returns the default in-flight snapshot ingestion bounds.
func InFlightLimitsFromConfig ¶ added in v1.0.63
func InFlightLimitsFromConfig(cfg config.CredentialInFlightConfig) (InFlightLimits, error)
InFlightLimitsFromConfig converts validated observation config into ingest limits.
type InFlightObservationReadModel ¶ added in v1.0.63
type InFlightObservationReadModel struct {
ObservedAt *time.Time
FreshUntil *time.Time
Stale bool
CoverageComplete bool
AggregatesComplete bool
ProtocolCoverageComplete bool
MinimumProcessedBarrierRevision *int64
DetailsTruncated bool
Credentials []InFlightObservedCredentialItem
Details []InFlightRequestDetail
}
InFlightObservationReadModel is the active-membership view of in-flight snapshots.
type InFlightObservedCredentialItem ¶ added in v1.0.63
type InFlightObservedCredentialItem struct {
CredentialID string
ObservedInFlight int64
ObservedAccounted int64
ObservedUnaccounted int64
Models []InFlightObservedModelItem
}
InFlightObservedCredentialItem summarizes observation counts for one credential.
type InFlightObservedModelItem ¶ added in v1.0.63
type InFlightObservedModelItem struct {
Model string
ObservedInFlight int64
ObservedAccounted int64
ObservedUnaccounted int64
}
InFlightObservedModelItem summarizes observation counts for one credential model.
type InFlightRequestDetail ¶ added in v1.0.63
type InFlightSnapshotCursor ¶ added in v1.0.63
type InFlightSnapshotCursor struct {
Cursor string
CredentialID string
Model string
Observation InFlightObservationReadModel
States []CredentialConcurrencyState
Total int
CreatedAt time.Time
ExpiresAt time.Time
ReadAt time.Time
}
InFlightSnapshotCursor is one page from a short-lived immutable Management API view.
type InFlightSnapshotCursorInput ¶ added in v1.0.63
type InFlightSnapshotCursorInput struct {
CredentialID string
Model string
Observation InFlightObservationReadModel
States []CredentialConcurrencyState
}
InFlightSnapshotCursorInput is the immutable observation captured for stable Management API pagination.
type InFlightSnapshotFrame ¶ added in v1.0.63
type InFlightSnapshotFrame struct {
Kind InFlightFrameKind `json:"kind"`
Revision int64 `json:"revision"`
ObservedAt time.Time `json:"observed_at"`
BarrierRevision int64 `json:"barrier_revision"`
PartIndex *int `json:"part_index,omitempty"`
PartCount *int `json:"part_count,omitempty"`
DetailsTruncated bool `json:"details_truncated,omitempty"`
Aggregates []InFlightAggregate `json:"aggregates,omitempty"`
Details []InFlightRequestDetail `json:"details,omitempty"`
AggregateGroupCount int `json:"aggregate_group_count,omitempty"`
}
type InFlightSnapshotPayload ¶ added in v1.0.63
type InFlightSnapshotPayload struct {
Aggregates []InFlightAggregate `json:"aggregates"`
Details []InFlightRequestDetail `json:"details"`
DetailsTruncated bool `json:"details_truncated"`
}
InFlightSnapshotPayload is the complete, visible payload for one revision.
type JSONB ¶
type JSONB []byte
func NormalizeJSONB ¶ added in v1.0.44
func NormalizeJSONB(raw json.RawMessage) (*JSONB, error)
NormalizeJSONB validates and normalizes raw JSON for JSONB fields.
func (JSONB) GormDBDataType ¶ added in v1.0.44
GormDBDataType returns the dialect-specific database type.
func (JSONB) GormDataType ¶ added in v1.0.44
GormDataType returns the logical GORM data type.
func (*JSONB) UnmarshalJSON ¶
UnmarshalJSON decodes a json.
type KVGetResult ¶ added in v1.0.44
type KVRecord ¶ added in v1.0.44
type KVRecord struct {
Key string `gorm:"column:key;primaryKey"`
Value []byte `gorm:"column:value;not null"`
Version int64 `gorm:"column:version;not null;default:1"`
ExpiresAt *time.Time `gorm:"column:expires_at;index"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
type LifecycleConfigRecord ¶ added in v1.0.63
type LifecycleConfigRecord struct {
ID int `gorm:"column:id;primaryKey"`
Revision int64 `gorm:"column:revision;not null"`
NodeHeartbeatTimeout time.Duration `gorm:"column:node_heartbeat_timeout;not null"`
Payload JSONB `gorm:"column:payload;not null"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
LifecycleConfigRecord stores the singleton credential concurrency lifecycle configuration.
func (LifecycleConfigRecord) TableName ¶ added in v1.0.63
func (LifecycleConfigRecord) TableName() string
type ManagementInFlightSnapshotCursorItemRecord ¶ added in v1.0.63
type ManagementInFlightSnapshotCursorItemRecord struct {
Cursor string `gorm:"column:cursor;primaryKey;size:64"`
Ordinal int64 `gorm:"column:ordinal;primaryKey"`
RequestID string `gorm:"column:request_id;not null"`
CredentialID string `gorm:"column:credential_id;not null;index"`
Model string `gorm:"column:model;not null"`
RequestKind string `gorm:"column:request_kind;not null"`
StartedAt time.Time `gorm:"column:started_at;not null"`
ObservedPresent bool `gorm:"column:observed_present;not null"`
StatePresent bool `gorm:"column:state_present;not null"`
}
ManagementInFlightSnapshotCursorItemRecord stores one stable request row.
func (ManagementInFlightSnapshotCursorItemRecord) TableName ¶ added in v1.0.63
func (ManagementInFlightSnapshotCursorItemRecord) TableName() string
type ManagementInFlightSnapshotCursorObservedRecord ¶ added in v1.0.63
type ManagementInFlightSnapshotCursorObservedRecord struct {
Cursor string `gorm:"column:cursor;primaryKey;size:64"`
CredentialID string `gorm:"column:credential_id;primaryKey;size:256"`
ObservedInFlight int64 `gorm:"column:observed_in_flight;not null"`
ObservedAccounted int64 `gorm:"column:observed_accounted;not null"`
ObservedUnaccounted int64 `gorm:"column:observed_unaccounted;not null"`
}
ManagementInFlightSnapshotCursorObservedRecord stores the minimum per-credential observation required to recompute limiter diagnostics.
func (ManagementInFlightSnapshotCursorObservedRecord) TableName ¶ added in v1.0.63
func (ManagementInFlightSnapshotCursorObservedRecord) TableName() string
type ManagementInFlightSnapshotCursorRecord ¶ added in v1.0.63
type ManagementInFlightSnapshotCursorRecord struct {
Cursor string `gorm:"column:cursor;primaryKey;size:64"`
SchemaVersion int `gorm:"column:schema_version;not null;default:0"`
CredentialID string `gorm:"column:credential_id;not null;default:''"`
Model string `gorm:"column:model;not null;default:''"`
ObservedAt *time.Time `gorm:"column:observed_at"`
FreshUntil *time.Time `gorm:"column:fresh_until"`
Stale bool `gorm:"column:stale;not null;default:false"`
CoverageComplete bool `gorm:"column:coverage_complete;not null;default:false"`
AggregatesComplete bool `gorm:"column:aggregates_complete;not null;default:false"`
ProtocolCoverageComplete bool `gorm:"column:protocol_coverage_complete;not null;default:false"`
MinimumProcessedBarrierRevision *int64 `gorm:"column:minimum_processed_barrier_revision"`
DetailsTruncated bool `gorm:"column:details_truncated;not null;default:false"`
Total int64 `gorm:"column:total;not null;default:0"`
Payload JSONB `gorm:"column:payload;not null"`
ExpiresAt time.Time `gorm:"column:expires_at;not null;index"`
CreatedAt time.Time `gorm:"column:created_at;not null;index"`
}
ManagementInFlightSnapshotCursorRecord stores the header for a short-lived immutable Management API view used to keep pagination on one observation.
func (ManagementInFlightSnapshotCursorRecord) TableName ¶ added in v1.0.63
func (ManagementInFlightSnapshotCursorRecord) TableName() string
type ManagementInFlightSnapshotCursorStateModelRecord ¶ added in v1.0.63
type ManagementInFlightSnapshotCursorStateModelRecord struct {
Cursor string `gorm:"column:cursor;primaryKey;size:64"`
CredentialID string `gorm:"column:credential_id;primaryKey;size:256"`
Model string `gorm:"column:model;primaryKey;size:256"`
MaxInFlight int64 `gorm:"column:max_in_flight;not null"`
AdmittedInFlight int64 `gorm:"column:admitted_in_flight;not null"`
}
ManagementInFlightSnapshotCursorStateModelRecord stores one pinned model limiter row for a credential state.
func (ManagementInFlightSnapshotCursorStateModelRecord) TableName ¶ added in v1.0.63
func (ManagementInFlightSnapshotCursorStateModelRecord) TableName() string
type ManagementInFlightSnapshotCursorStateRecord ¶ added in v1.0.63
type ManagementInFlightSnapshotCursorStateRecord struct {
Cursor string `gorm:"column:cursor;primaryKey;size:64"`
CredentialID string `gorm:"column:credential_id;primaryKey;size:256"`
MaxInFlight *int64 `gorm:"column:max_in_flight"`
AdmittedInFlight int64 `gorm:"column:admitted_in_flight;not null"`
PolicyVersion int64 `gorm:"column:policy_version;not null"`
EffectiveAt time.Time `gorm:"column:effective_at;not null"`
ObservationBarrier int64 `gorm:"column:observation_barrier;not null"`
ModelCount int64 `gorm:"column:model_count;not null"`
}
ManagementInFlightSnapshotCursorStateRecord stores one pinned authoritative credential limiter state.
func (ManagementInFlightSnapshotCursorStateRecord) TableName ¶ added in v1.0.63
func (ManagementInFlightSnapshotCursorStateRecord) TableName() string
type ModelGroupDetailFilter ¶ added in v1.0.44
type ModelGroupDetailRecord ¶ added in v1.0.44
type ModelGroupDetailRecord struct {
ID uint `` /* 212-byte string literal not displayed */
ModelGroupID uint `` /* 208-byte string literal not displayed */
ModelID string `gorm:"column:model_id;not null;index:idx_model_group_detail_model_active_order,priority:1"`
Channels JSONB `gorm:"column:channels"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
DeletedAt gorm.DeletedAt `` /* 201-byte string literal not displayed */
}
func (ModelGroupDetailRecord) TableName ¶ added in v1.0.44
func (ModelGroupDetailRecord) TableName() string
TableName returns the database table name.
type ModelGroupDetailUpdate ¶ added in v1.0.44
type ModelGroupRecord ¶ added in v1.0.44
type ModelGroupRecord struct {
ID uint `` /* 134-byte string literal not displayed */
GroupName string `gorm:"column:group_name;not null"`
Disabled bool `gorm:"column:disabled;not null;default:false;index:idx_model_group_enabled_order,priority:2"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;index:idx_model_group_active_order,priority:1;index:idx_model_group_enabled_order,priority:1"`
}
func (ModelGroupRecord) TableName ¶ added in v1.0.44
func (ModelGroupRecord) TableName() string
TableName returns the database table name.
type ModelGroupUpdate ¶ added in v1.0.44
type NodeConfig ¶
type NodeConfig struct {
ExternalIP string `yaml:"external-ip"`
ExternalPort int `yaml:"external-port"`
Port int `yaml:"port"`
HeartbeatInterval time.Duration `yaml:"heartbeat-interval"`
HeartbeatTimeout time.Duration `yaml:"heartbeat-timeout"`
EventPollInterval time.Duration `yaml:"event-poll-interval"`
}
type NodeIdentity ¶
type OAuthSessionRecord ¶
type OAuthSessionRecord struct {
State string `gorm:"column:state;primaryKey"`
Provider string `gorm:"column:provider;index"`
Status string `gorm:"column:status"`
Error string `gorm:"column:error"`
Data JSONB `gorm:"column:data"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
ExpiresAt time.Time `gorm:"column:expires_at;index"`
CompletedAt *time.Time `gorm:"column:completed_at"`
}
func NewOAuthSessionRecord ¶
func NewOAuthSessionRecord(provider, state string, data map[string]any, now time.Time) (*OAuthSessionRecord, error)
NewOAuthSessionRecord creates a new o auth session record.
func (OAuthSessionRecord) TableName ¶
func (OAuthSessionRecord) TableName() string
TableName returns the database table name.
type OptionalFloatUpdate ¶ added in v1.0.63
type OptionalLimit ¶ added in v1.0.63
OptionalLimit distinguishes an omitted limit from JSON null and a numeric value.
func (*OptionalLimit) UnmarshalJSON ¶ added in v1.0.63
func (o *OptionalLimit) UnmarshalJSON(data []byte) error
UnmarshalJSON records JSON field presence for a policy limit.
type OptionalModelLimitMap ¶ added in v1.0.63
OptionalModelLimitMap distinguishes an omitted model map from JSON null and a map value.
func (*OptionalModelLimitMap) UnmarshalJSON ¶ added in v1.0.63
func (o *OptionalModelLimitMap) UnmarshalJSON(data []byte) error
UnmarshalJSON records JSON field presence for model policy limits.
type PGSQLConfig ¶
type PGSQLConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
User string `yaml:"user"`
Password string `yaml:"password"`
Passowrd string `yaml:"passowrd"`
Database string `yaml:"database"`
SSLMode string `yaml:"sslmode"`
}
func (PGSQLConfig) Configured ¶ added in v1.0.44
func (c PGSQLConfig) Configured() bool
Configured reports whether PostgreSQL has cluster database settings.
func (PGSQLConfig) DSN ¶
func (c PGSQLConfig) DSN() (string, error)
DSN returns the PostgreSQL connection string.
type PeriodLimitConfigError ¶ added in v1.0.63
type PeriodLimitConfigError struct {
Message string
// Field is the Management API field that failed validation (for example
// "limit_5h_credits" or "timezone"). Empty when not field-specific.
Field string
// Code is one of the PeriodLimitErr* constants. Empty for legacy errors.
Code string
}
PeriodLimitConfigError is returned for invalid period-limit configuration inputs.
func (PeriodLimitConfigError) Error ¶ added in v1.0.63
func (e PeriodLimitConfigError) Error() string
type PluginStatusRecord ¶ added in v1.0.44
type PluginStatusRecord struct {
NodeType string `gorm:"column:node_type;primaryKey;size:16;index:idx_plugin_status_node,priority:1;index:idx_plugin_status_plugin,priority:1"`
NodeID string `gorm:"column:node_id;primaryKey;size:128;index:idx_plugin_status_node,priority:2"`
PluginID string `gorm:"column:plugin_id;primaryKey;size:128;index:idx_plugin_status_plugin,priority:2"`
TaskID uint `gorm:"column:task_id;index"`
ClientIP string `gorm:"column:client_ip;index"`
SchemaVersion int `gorm:"column:schema_version"`
Task string `gorm:"column:task"`
TaskStatus string `gorm:"column:task_status;index"`
Phase string `gorm:"column:phase;index"`
OK bool `gorm:"column:ok;index"`
TaskError string `gorm:"column:task_error;type:text"`
StartedAt time.Time `gorm:"column:started_at"`
FinishedAt *time.Time `gorm:"column:finished_at"`
ReportedAt time.Time `gorm:"column:reported_at;index"`
GOOS string `gorm:"column:goos;index"`
GOARCH string `gorm:"column:goarch;index"`
Version string `gorm:"column:version"`
ReleaseTag string `gorm:"column:release_tag"`
Repository string `gorm:"column:repository;type:text"`
InstallStatus string `gorm:"column:install_status;index"`
LoadStatus string `gorm:"column:load_status;index"`
Path string `gorm:"column:path;type:text"`
Skipped bool `gorm:"column:skipped"`
Overwritten bool `gorm:"column:overwritten"`
PluginError string `gorm:"column:plugin_error;type:text"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (PluginStatusRecord) TableName ¶ added in v1.0.44
func (PluginStatusRecord) TableName() string
TableName returns the database table name.
type PluginStoreAuthKeyRecord ¶ added in v1.0.63
type PluginStoreAuthKeyRecord struct {
ID uint `gorm:"column:id;primaryKey"`
Key []byte `gorm:"column:key;not null"`
KeyVersion int `gorm:"column:key_version;not null"`
}
func (PluginStoreAuthKeyRecord) TableName ¶ added in v1.0.63
func (PluginStoreAuthKeyRecord) TableName() string
type PluginStoreAuthRecord ¶ added in v1.0.63
type PluginStoreAuthRecord struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement"`
Name string `gorm:"column:name;not null"`
Match string `gorm:"column:match;not null;type:text"`
ApplyTo JSONB `gorm:"column:apply_to"`
AuthType string `gorm:"column:auth_type;not null"`
HeaderName string `gorm:"column:header_name"`
EncryptedCredentials []byte `gorm:"column:encrypted_credentials"`
KeyVersion int `gorm:"column:key_version;not null"`
Enabled bool `gorm:"column:enabled;not null;default:true"`
Version int64 `gorm:"column:version;not null;default:1"`
}
func (PluginStoreAuthRecord) TableName ¶ added in v1.0.63
func (PluginStoreAuthRecord) TableName() string
type PluginStoreAuthSealFunc ¶ added in v1.0.63
type PluginTaskRecord ¶ added in v1.0.44
type PluginTaskRecord struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement"`
Operation string `gorm:"column:operation;size:32;index:idx_plugin_tasks_operation"`
PluginID string `gorm:"column:plugin_id;size:128;index:idx_plugin_tasks_plugin"`
TargetNodeType string `gorm:"column:target_node_type;size:16;index:idx_plugin_tasks_target,priority:1"`
TargetNodeID string `gorm:"column:target_node_id;size:128;index:idx_plugin_tasks_target,priority:2"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (PluginTaskRecord) TableName ¶ added in v1.0.44
func (PluginTaskRecord) TableName() string
TableName returns the database table name.
type ProxyPoolPatch ¶ added in v1.0.44
type ProxyPoolRecord ¶ added in v1.0.44
type ProxyPoolRecord struct {
ID string `gorm:"column:id;primaryKey"`
Name string `gorm:"column:name;not null"`
ProxyURL string `gorm:"column:proxy_url;not null"`
Enabled bool `gorm:"column:enabled;not null;default:true"`
Scope string `gorm:"column:scope;not null;default:global;index:idx_proxy_pool_scope_priority,priority:1"`
Priority int `gorm:"column:priority;not null;default:0;index:idx_proxy_pool_scope_priority,priority:2"`
LastTestedAt *time.Time `gorm:"column:last_tested_at"`
LastTestResult string `gorm:"column:last_test_result;not null;default:untested"`
Note string `gorm:"column:note;type:text"`
CreatedAt time.Time `gorm:"column:created_at;index:idx_proxy_pool_scope_priority,priority:3"`
UpdatedAt time.Time `gorm:"column:updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index"`
}
func (ProxyPoolRecord) TableName ¶ added in v1.0.44
func (ProxyPoolRecord) TableName() string
type ProxyPoolUpdate ¶ added in v1.0.44
type QuotaCollectionError ¶ added in v1.0.63
type QuotaCredentialSnapshot ¶ added in v1.0.63
type QuotaCredentialSnapshot struct {
CredentialID string `json:"credential_id"`
AuthIndex *string `json:"auth_index"`
Provider string `json:"provider"`
CredentialType string `json:"credential_type"`
Label string `json:"label"`
Account *string `json:"account"`
Project *string `json:"project"`
CredentialStatus string `json:"credential_status"`
QuotaStatus string `json:"quota_status"`
Freshness string `json:"freshness"`
CollectionStatus string `json:"collection_status"`
Source *string `json:"source"`
ObservedAt *time.Time `json:"observed_at"`
ExpiresAt *time.Time `json:"expires_at"`
EarliestResetAt *time.Time `json:"earliest_reset_at"`
LastAttemptAt *time.Time `json:"last_attempt_at"`
LastSuccessAt *time.Time `json:"last_success_at"`
NextProbeAt *time.Time `json:"next_probe_at"`
ConsecutiveFailure int `json:"consecutive_failures"`
PrimaryWindows []QuotaWindow `json:"primary_windows"`
WindowCount int `json:"window_count"`
Error *QuotaCollectionError `json:"error"`
Runtime *QuotaRuntime `json:"runtime"`
Plan *QuotaPlan `json:"plan,omitempty"`
ResetCredits *QuotaResetCredits `json:"-"`
Windows []QuotaWindow `json:"-"`
}
type QuotaFacetOption ¶ added in v1.0.63
type QuotaFacets ¶ added in v1.0.63
type QuotaFacets struct {
Providers []QuotaFacetOption `json:"providers"`
QuotaStatuses []QuotaFacetOption `json:"quota_statuses"`
Freshness []QuotaFacetOption `json:"freshness"`
Sources []QuotaFacetOption `json:"sources"`
CredentialStatuses []QuotaFacetOption `json:"credential_statuses"`
CollectionStatuses []QuotaFacetOption `json:"collection_statuses"`
}
type QuotaListQuery ¶ added in v1.0.63
type QuotaListQuery struct {
Limit int
Offset int
Search string
IDs map[string]struct{}
Providers map[string]struct{}
QuotaStatuses map[string]struct{}
Freshness map[string]struct{}
Sources map[string]struct{}
CredentialStatuses map[string]struct{}
CollectionStatuses map[string]struct{}
Sort string
Now time.Time
}
type QuotaListResult ¶ added in v1.0.63
type QuotaListResult struct {
Items []QuotaCredentialSnapshot
Total int
Summary QuotaSummary
GlobalSummary QuotaSummary
Facets QuotaFacets
}
type QuotaPlan ¶ added in v1.0.63
QuotaPlan carries subscription plan metadata derived from a provider's quota response (for example Codex Pro 20x or xAI SuperGrok Heavy).
type QuotaResetCredit ¶ added in v1.0.63
type QuotaResetCredit struct {
ID string `json:"id"`
Status string `json:"status"`
GrantedAt time.Time `json:"granted_at"`
ExpiresAt *time.Time `json:"expires_at"`
}
QuotaResetCredit describes one available provider-issued quota reset credit.
type QuotaResetCredits ¶ added in v1.0.63
type QuotaResetCredits struct {
AvailableCount *int `json:"available_count"`
ObservedAt time.Time `json:"observed_at"`
Credits []QuotaResetCredit `json:"credits"`
}
QuotaResetCredits carries the latest normalized reset-credit observation.
type QuotaRuntime ¶ added in v1.0.63
type QuotaSnapshotRecord ¶ added in v1.0.63
type QuotaSnapshotRecord struct {
CredentialID string `gorm:"column:credential_id;primaryKey;size:128"`
QuotaStatus string `gorm:"column:quota_status;not null;size:32;index"`
CollectionStatus string `gorm:"column:collection_status;not null;size:32;index"`
Source string `gorm:"column:source;size:32;index"`
ObservedAt *time.Time `gorm:"column:observed_at;index"`
ExpiresAt *time.Time `gorm:"column:expires_at;index"`
LastAttemptAt *time.Time `gorm:"column:last_attempt_at"`
LastSuccessAt *time.Time `gorm:"column:last_success_at"`
NextProbeAt *time.Time `gorm:"column:next_probe_at;index"`
ConsecutiveFailure int `gorm:"column:consecutive_failures;not null;default:0"`
ErrorCode string `gorm:"column:error_code;size:128"`
ErrorMessage string `gorm:"column:error_message;size:500"`
ErrorRetryable bool `gorm:"column:error_retryable;not null;default:false"`
ErrorOccurredAt *time.Time `gorm:"column:error_occurred_at"`
ErrorStatusCode int `gorm:"column:error_status_code;not null;default:0"`
ErrorRequestID string `gorm:"column:error_request_id;size:128"`
HomeID string `gorm:"column:home_id;size:256"`
HomeLabel string `gorm:"column:home_label;size:256"`
CPANodeID string `gorm:"column:cpa_node_id;size:256"`
CPANodeLabel string `gorm:"column:cpa_node_label;size:256"`
PlanName string `gorm:"column:plan_name;size:64"`
PlanPremium *bool `gorm:"column:plan_premium"`
ResetCredits JSONB `gorm:"column:reset_credits"`
ProbeLeaseOwner string `gorm:"column:probe_lease_owner;size:256"`
ProbeLeaseExpiresAt *time.Time `gorm:"column:probe_lease_expires_at;index"`
ParserVersion int `gorm:"column:parser_version;not null;default:1"`
CollectorVersion int `gorm:"column:collector_version;not null;default:1"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (QuotaSnapshotRecord) TableName ¶ added in v1.0.63
func (QuotaSnapshotRecord) TableName() string
type QuotaSnapshotWrite ¶ added in v1.0.63
type QuotaSnapshotWrite struct {
CredentialID string
QuotaStatus string
CollectionStatus string
Source string
ObservedAt *time.Time
ReceivedAt *time.Time
MaxAcceptedObservedAt *time.Time
ExpiresAt *time.Time
LastAttemptAt *time.Time
LastSuccessAt *time.Time
NextProbeAt *time.Time
ConsecutiveFailure int
Error *QuotaCollectionError
Runtime *QuotaRuntime
Plan *QuotaPlan
ReplacePlan bool
ResetCredits *QuotaResetCredits
ReplaceResetCredits bool
ParserVersion int
CollectorVersion int
ExpectedProbeOwner string
ClearProbeLease bool
ReplaceWindows bool
Windows []QuotaWindow
}
type QuotaSummary ¶ added in v1.0.63
type QuotaSummary struct {
TotalCredentials int `json:"total_credentials"`
Healthy int `json:"healthy"`
Low int `json:"low"`
Exhausted int `json:"exhausted"`
Unknown int `json:"unknown"`
Error int `json:"error"`
Unsupported int `json:"unsupported"`
Stale int `json:"stale"`
Never int `json:"never"`
Collecting int `json:"collecting"`
NeedsAttention int `json:"needs_attention"`
LastObservedAt *time.Time `json:"last_observed_at"`
}
type QuotaWindow ¶ added in v1.0.63
type QuotaWindow struct {
ID string `json:"id"`
Label *string `json:"label"`
Scope string `json:"scope"`
ScopeID *string `json:"scope_id"`
Mode string `json:"mode"`
Status string `json:"status"`
Unit string `json:"unit"`
Currency *string `json:"currency"`
Used *float64 `json:"used"`
Remaining *float64 `json:"remaining"`
Limit *float64 `json:"limit"`
UsedRatio *float64 `json:"used_ratio"`
RemainingRatio *float64 `json:"remaining_ratio"`
IsUnlimited bool `json:"is_unlimited"`
ResetAt *time.Time `json:"reset_at"`
WindowSeconds *int64 `json:"window_seconds"`
PeriodUnit string `json:"period_unit"`
PeriodValue *float64 `json:"period_value"`
Source string `json:"source"`
ObservedAt time.Time `json:"observed_at"`
ExpiresAt *time.Time `json:"-"`
Priority int `json:"-"`
}
type QuotaWindowRecord ¶ added in v1.0.63
type QuotaWindowRecord struct {
CredentialID string `gorm:"column:credential_id;primaryKey;size:128;index:idx_quota_window_credential_order,priority:1"`
WindowID string `gorm:"column:window_id;primaryKey;size:256;index:idx_quota_window_credential_order,priority:2"`
Priority int `gorm:"column:priority;not null;default:0;index:idx_quota_window_credential_order,priority:3"`
Label string `gorm:"column:label;size:256"`
Scope string `gorm:"column:scope;not null;size:32"`
ScopeID string `gorm:"column:scope_id;size:256"`
Mode string `gorm:"column:mode;not null;size:32"`
Status string `gorm:"column:status;not null;size:32"`
Unit string `gorm:"column:unit;not null;size:32"`
Currency string `gorm:"column:currency;size:16"`
Used *float64 `gorm:"column:used"`
Remaining *float64 `gorm:"column:remaining"`
Limit *float64 `gorm:"column:limit_value"`
UsedRatio *float64 `gorm:"column:used_ratio"`
RemainingRatio *float64 `gorm:"column:remaining_ratio"`
IsUnlimited bool `gorm:"column:is_unlimited;not null;default:false"`
ResetAt *time.Time `gorm:"column:reset_at;index"`
WindowSeconds *int64 `gorm:"column:window_seconds"`
PeriodUnit string `gorm:"column:period_unit;not null;size:32"`
PeriodValue *float64 `gorm:"column:period_value"`
Source string `gorm:"column:source;not null;size:32"`
ObservedAt time.Time `gorm:"column:observed_at;not null;index"`
ExpiresAt *time.Time `gorm:"column:expires_at;index"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (QuotaWindowRecord) TableName ¶ added in v1.0.63
func (QuotaWindowRecord) TableName() string
type RESPHandler ¶
type RESPHandler struct {
// contains filtered or unexported fields
}
func NewRESPHandler ¶
func NewRESPHandler(coordinator *Coordinator, refresh *RefreshController, repo *Repository) *RESPHandler
NewRESPHandler creates a new resp handler.
func (*RESPHandler) BeginFingerprintCancellation ¶ added in v1.0.63
func (h *RESPHandler) BeginFingerprintCancellation(ctx context.Context, fingerprint string) (int64, error)
UpdateClientCount stores the current active CPA client count for this node. BeginFingerprintCancellation starts distributed cancellation for an ambiguous dispatch delivery.
func (*RESPHandler) ClassifyConnection ¶ added in v1.0.63
func (h *RESPHandler) ClassifyConnection(ctx context.Context, fingerprint string) (ConnectionLifetime, error)
ClassifyConnection classifies a CPA connection using this command Home incarnation.
func (*RESPHandler) RefreshCPALiveness ¶ added in v1.0.63
func (h *RESPHandler) RefreshCPALiveness(ctx context.Context, lifetime ConnectionLifetime) error
SubscribeMembership creates a membership owned by this Home incarnation. RefreshCPALiveness records a successful subscription heartbeat for the exact lifetime.
func (*RESPHandler) RequestClientCertificate ¶ added in v1.0.44
func (h *RESPHandler) RequestClientCertificate(ctx context.Context, certificateID string, enrollmentSecret string, csrPEM []byte) ([]byte, error)
RequestClientCertificate signs a pending client certificate request.
func (*RESPHandler) SubscribeMembership ¶ added in v1.0.63
func (h *RESPHandler) SubscribeMembership(ctx context.Context, fingerprint string, nodeID string, protocolVersion int, lifecycleConfigRevision int64) (ConnectionLifetime, error)
SubscribeMembership creates a membership owned by this Home incarnation.
func (*RESPHandler) UpdateClientCount ¶
func (h *RESPHandler) UpdateClientCount(ctx context.Context, clientCount int) error
type RefreshController ¶
type RefreshController struct {
// contains filtered or unexported fields
}
func NewRefreshController ¶
func NewRefreshController(coordinator *Coordinator, runtime *home.Runtime, repo *Repository, forwardTLSConfig *tls.Config) *RefreshController
NewRefreshController creates a new refresh controller.
func (*RefreshController) CanAutoRefresh ¶
func (c *RefreshController) CanAutoRefresh() bool
CanAutoRefresh reports whether can auto refresh.
func (*RefreshController) OnMasterChanged ¶
func (c *RefreshController) OnMasterChanged(isMaster bool)
OnMasterChanged handles an on master changed.
func (*RefreshController) RefreshNow ¶
RefreshNow refreshes refresh now.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db *gorm.DB) *Repository
NewRepository creates a new repository.
func (*Repository) AcknowledgeQuiescence ¶ added in v1.0.63
func (r *Repository) AcknowledgeQuiescence(ctx context.Context, fingerprint string, connectedAt time.Time, revision int64, home HomeIncarnationID) error
AcknowledgeQuiescence records one active Home's successful local fence for the current lifetime.
func (*Repository) AdmitCredentialConcurrency ¶ added in v1.0.63
func (r *Repository) AdmitCredentialConcurrency(ctx context.Context, req ConcurrencyAdmissionRequest) (ConcurrencyAdmissionResult, error)
AdmitCredentialConcurrency atomically checks configured limits and records one admitted request.
func (*Repository) AllowUserSecurityActionWithRetry ¶ added in v1.0.63
func (r *Repository) AllowUserSecurityActionWithRetry(ctx context.Context, action string, scopeHash string, limit int, window time.Duration, now time.Time) (bool, time.Duration, error)
AllowUserSecurityActionWithRetry increments an anchored-window counter and reports how long a denied caller must wait before the current window resets.
func (*Repository) AllowedAuthIDsForAPIKey ¶ added in v1.0.44
AllowedAuthIDsForAPIKey returns auth IDs allowed by the API key channel bindings.
func (*Repository) AllowedDispatchIDsForAPIKey ¶ added in v1.0.44
func (r *Repository) AllowedDispatchIDsForAPIKey(ctx context.Context, apiKey string) ([]string, []string, error)
AllowedDispatchIDsForAPIKey returns auth and model IDs allowed by API-key bindings.
func (*Repository) AllowedDispatchIDsForAPIKeyModel ¶ added in v1.0.63
func (r *Repository) AllowedDispatchIDsForAPIKeyModel(ctx context.Context, apiKey string, modelID string) ([]string, []string, error)
AllowedDispatchIDsForAPIKeyModel returns auth and model IDs after applying model-specific channel bindings.
func (*Repository) AllowedModelIDsForAPIKey ¶ added in v1.0.44
AllowedModelIDsForAPIKey returns model IDs allowed by the API key model group bindings.
func (*Repository) AppendAppLog ¶ added in v1.0.44
func (r *Repository) AppendAppLog(ctx context.Context, clientIP string, homeIP string, payload string) (*AppLogRecord, error)
AppendAppLog appends a CPA application log record.
func (*Repository) AppendEvent ¶
func (r *Repository) AppendEvent(ctx context.Context, scope, op, entity string, version int64) error
AppendEvent appends an event.
func (*Repository) AppendUsage ¶
func (r *Repository) AppendUsage(ctx context.Context, payload string, homeIP string) (*UsageRecord, error)
AppendUsage appends an usage.
func (*Repository) AppendUsageWithRuntime ¶ added in v1.0.63
func (r *Repository) AppendUsageWithRuntime(ctx context.Context, payload string, metadata UsageRuntimeMetadata) (*UsageRecord, error)
AppendUsageWithRuntime appends usage with trusted Home/CPA runtime metadata.
func (*Repository) ApplyBillingBalanceRecord ¶ added in v1.0.44
func (r *Repository) ApplyBillingBalanceRecord(ctx context.Context, update BillingBalanceUpdate) (*BillingBalanceRecord, error)
func (*Repository) ApplyBillingModelPriceImport ¶ added in v1.0.63
func (r *Repository) ApplyBillingModelPriceImport(ctx context.Context, input BillingModelPriceImportApplyInput) (*BillingModelPriceImportOperation, error)
func (*Repository) ApplyConcurrencyRelease ¶ added in v1.0.63
func (r *Repository) ApplyConcurrencyRelease(ctx context.Context, req ConcurrencyReleaseRequest) error
ApplyConcurrencyRelease atomically applies a cumulative release sequence.
func (*Repository) BeginFingerprintCancellation ¶ added in v1.0.63
func (r *Repository) BeginFingerprintCancellation(ctx context.Context, fingerprint string) (int64, error)
BeginFingerprintCancellation creates the exact Home acknowledgement set for an active membership.
func (*Repository) BillingOverview ¶ added in v1.0.44
func (r *Repository) BillingOverview(ctx context.Context, query BillingOverviewQuery) (BillingOverview, error)
func (*Repository) BuildUserPeriodLimitsStatus ¶ added in v1.0.63
func (r *Repository) BuildUserPeriodLimitsStatus(ctx context.Context, userID uint, now time.Time) (UserPeriodLimitsStatus, error)
BuildUserPeriodLimitsStatus computes used/remaining for management APIs.
func (*Repository) ClaimEligibleQuotaProbe ¶ added in v1.0.63
func (r *Repository) ClaimEligibleQuotaProbe(ctx context.Context, credentialID string, owner string, now time.Time, leaseDuration time.Duration) (bool, error)
ClaimEligibleQuotaProbe claims a lease only while the current DB credential remains eligible.
func (*Repository) ClaimQuotaProbe ¶ added in v1.0.63
func (*Repository) ClaimUserMailJob ¶ added in v1.0.63
func (r *Repository) ClaimUserMailJob(ctx context.Context, workerID string, now time.Time, lease time.Duration) (*UserMailJobRecord, error)
ClaimUserMailJob atomically leases one ready job to a worker.
func (*Repository) ClassifyConnection ¶ added in v1.0.63
func (r *Repository) ClassifyConnection(ctx context.Context, fingerprint string, home HomeIncarnationID) (ConnectionLifetime, error)
ClassifyConnection determines whether a connection belongs to an active membership.
func (*Repository) CleanupExpiredInFlightStaging ¶ added in v1.0.63
func (r *Repository) CleanupExpiredInFlightStaging(ctx context.Context, retention time.Duration) error
CleanupExpiredInFlightStaging rejects expired staging only after its membership lifetime is no longer active.
func (*Repository) CleanupInFlightLifetime ¶ added in v1.0.63
func (r *Repository) CleanupInFlightLifetime(ctx context.Context, fingerprint string, connectedAt time.Time) error
CleanupInFlightLifetime removes observation rows for one closed CPA membership lifetime.
func (*Repository) CleanupStaleMemberships ¶ added in v1.0.63
func (r *Repository) CleanupStaleMemberships(ctx context.Context) error
CleanupStaleMemberships begins cancellation for active memberships whose database liveness has expired.
func (*Repository) ClientCertificateFingerprintActive ¶ added in v1.0.63
func (*Repository) ClusterCAKeyPair ¶ added in v1.0.44
func (r *Repository) ClusterCAKeyPair(ctx context.Context) (*x509.Certificate, *rsa.PrivateKey, error)
ClusterCAKeyPair returns the cluster root CA certificate and private key.
func (*Repository) CompleteFingerprintCancellation ¶ added in v1.0.63
func (r *Repository) CompleteFingerprintCancellation(ctx context.Context, fingerprint string, connectedAt time.Time, revision int64) error
CompleteFingerprintCancellation closes a membership only after every expected Home has quiesced.
func (*Repository) CompleteOAuthSession ¶
func (r *Repository) CompleteOAuthSession(ctx context.Context, state string) error
CompleteOAuthSession handles a complete o auth session.
func (*Repository) CompleteUserMailJob ¶ added in v1.0.63
func (r *Repository) CompleteUserMailJob(ctx context.Context, jobID uint, workerID string, now time.Time) error
CompleteUserMailJob marks a claimed job as sent.
func (*Repository) ConsumeUserEmailVerificationToken ¶ added in v1.0.63
func (r *Repository) ConsumeUserEmailVerificationToken(ctx context.Context, tokenHash string, now time.Time) (*UserRecord, error)
ConsumeUserEmailVerificationToken verifies an email token and marks the current email as verified.
func (*Repository) ConsumeUserPasswordResetToken ¶ added in v1.0.63
func (r *Repository) ConsumeUserPasswordResetToken(ctx context.Context, tokenHash string, passwordHash string, now time.Time) (*UserRecord, error)
ConsumeUserPasswordResetToken updates the password, revokes sessions, and consumes the reset token.
func (*Repository) CreateAPIKey ¶ added in v1.0.63
func (r *Repository) CreateAPIKey(ctx context.Context, update APIKeyEntryUpdate) (*APIKeyRecord, error)
CreateAPIKey creates or restores one API key without replacing the full key list.
func (*Repository) CreateAPIKeyForUser ¶ added in v1.0.44
func (r *Repository) CreateAPIKeyForUser(ctx context.Context, userID uint, update APIKeyUserUpdate) (*APIKeyRecord, error)
CreateAPIKeyForUser creates an API key owned by one user.
func (*Repository) CreateBillingModelPrice ¶ added in v1.0.44
func (r *Repository) CreateBillingModelPrice(ctx context.Context, update BillingModelPriceUpdate) (*BillingModelPriceRecord, error)
func (*Repository) CreateBillingModelPriceImportPreview ¶ added in v1.0.63
func (r *Repository) CreateBillingModelPriceImportPreview(ctx context.Context, input BillingModelPriceImportPreviewInput, catalog BillingModelPriceImportCatalog) (*BillingModelPriceImportPreview, error)
func (*Repository) CreateChannelGroup ¶ added in v1.0.44
func (r *Repository) CreateChannelGroup(ctx context.Context, channelName string, disabled bool) (*ChannelGroupRecord, error)
CreateChannelGroup creates a channel group.
func (*Repository) CreateChannelGroupDetail ¶ added in v1.0.44
func (r *Repository) CreateChannelGroupDetail(ctx context.Context, channelGroupID uint, authID string) (*ChannelGroupDetailRecord, error)
CreateChannelGroupDetail creates a channel group detail.
func (*Repository) CreateHomeJWT ¶ added in v1.0.44
func (r *Repository) CreateHomeJWT(ctx context.Context, certificateID string, ip string, port int, enrollmentSecret string) (string, error)
CreateHomeJWT creates a signed Home JWT with the client certificate id and target node.
func (*Repository) CreateInFlightSnapshotCursor ¶ added in v1.0.63
func (r *Repository) CreateInFlightSnapshotCursor(ctx context.Context, input InFlightSnapshotCursorInput, ttl time.Duration) (InFlightSnapshotCursor, error)
CreateInFlightSnapshotCursor persists one immutable relational view for stable pagination.
func (*Repository) CreateModelGroup ¶ added in v1.0.44
func (r *Repository) CreateModelGroup(ctx context.Context, groupName string, disabled bool) (*ModelGroupRecord, error)
CreateModelGroup creates a model group.
func (*Repository) CreateModelGroupDetail ¶ added in v1.0.44
func (r *Repository) CreateModelGroupDetail(ctx context.Context, modelGroupID uint, modelID string, channels []uint) (*ModelGroupDetailRecord, error)
CreateModelGroupDetail creates a model group detail.
func (*Repository) CreatePendingClientCertificate ¶ added in v1.0.44
CreatePendingClientCertificate creates an empty client certificate slot.
func (*Repository) CreatePluginStoreAuth ¶ added in v1.0.63
func (r *Repository) CreatePluginStoreAuth(ctx context.Context, record *PluginStoreAuthRecord, seal PluginStoreAuthSealFunc) error
func (*Repository) CreatePluginTask ¶ added in v1.0.44
func (r *Repository) CreatePluginTask(ctx context.Context, task node.PluginTask) (node.PluginTask, error)
CreatePluginTask stores a plugin task and emits a cluster event to wake peers.
func (*Repository) CreateProxyPoolItem ¶ added in v1.0.44
func (r *Repository) CreateProxyPoolItem(ctx context.Context, update ProxyPoolUpdate) (*ProxyPoolRecord, error)
func (*Repository) CreateUser ¶ added in v1.0.44
func (r *Repository) CreateUser(ctx context.Context, update UserUpdate) (*UserRecord, error)
CreateUser creates a user.
func (*Repository) CurrentMasterNode ¶ added in v1.0.44
func (r *Repository) CurrentMasterNode(ctx context.Context) (*ClusterNodeRecord, error)
CurrentMasterNode returns the current master node if one is recorded.
func (*Repository) DeleteAPIKey ¶ added in v1.0.63
func (r *Repository) DeleteAPIKey(ctx context.Context, selector APIKeySelector) error
DeleteAPIKey deletes one API key selected by stable ID or a legacy selector.
func (*Repository) DeleteAPIKeyForUser ¶ added in v1.0.44
func (r *Repository) DeleteAPIKeyForUser(ctx context.Context, userID uint, id uint, apiKey string) error
DeleteAPIKeyForUser deletes one API key owned by one user.
func (*Repository) DeleteAppLogs ¶ added in v1.0.63
func (r *Repository) DeleteAppLogs(ctx context.Context) (int64, error)
DeleteAppLogs deletes all CPA application log records.
func (*Repository) DeleteBillingModelPrice ¶ added in v1.0.44
func (r *Repository) DeleteBillingModelPrice(ctx context.Context, id string) error
func (*Repository) DeleteChannelGroup ¶ added in v1.0.44
func (r *Repository) DeleteChannelGroup(ctx context.Context, id uint) error
DeleteChannelGroup deletes a channel group and its details.
func (*Repository) DeleteChannelGroupDetail ¶ added in v1.0.44
func (r *Repository) DeleteChannelGroupDetail(ctx context.Context, id uint) error
DeleteChannelGroupDetail deletes a channel group detail.
func (*Repository) DeleteModelGroup ¶ added in v1.0.44
func (r *Repository) DeleteModelGroup(ctx context.Context, id uint) error
DeleteModelGroup deletes a model group and its details.
func (*Repository) DeleteModelGroupDetail ¶ added in v1.0.44
func (r *Repository) DeleteModelGroupDetail(ctx context.Context, id uint) error
DeleteModelGroupDetail deletes a model group detail.
func (*Repository) DeletePluginStoreAuth ¶ added in v1.0.63
func (r *Repository) DeletePluginStoreAuth(ctx context.Context, id uint) error
func (*Repository) DeleteProxyPoolItem ¶ added in v1.0.44
func (r *Repository) DeleteProxyPoolItem(ctx context.Context, id string) error
func (*Repository) DeleteUser ¶ added in v1.0.44
func (r *Repository) DeleteUser(ctx context.Context, id uint) error
DeleteUser deletes a user.
func (*Repository) DialectName ¶ added in v1.0.63
func (r *Repository) DialectName() string
DialectName returns the repository database dialect.
func (*Repository) EnqueueUserMailJob ¶ added in v1.0.63
func (r *Repository) EnqueueUserMailJob(ctx context.Context, userID uint, purpose string, emailVersion uint64, now time.Time) (*UserMailJobRecord, error)
EnqueueUserMailJob supersedes older pending jobs for the same purpose.
func (*Repository) EnsureClusterCertificates ¶ added in v1.0.44
EnsureClusterCertificates makes sure the cluster CA and this node server certificate exist.
func (*Repository) EnsureLifecycleConfig ¶ added in v1.0.63
func (r *Repository) EnsureLifecycleConfig(ctx context.Context, nodeHeartbeatTimeout time.Duration) (LifecycleConfigRecord, error)
EnsureLifecycleConfig creates the singleton lifecycle configuration when absent.
func (*Repository) EnsurePluginStoreAuthKey ¶ added in v1.0.63
func (*Repository) ExportCredentialConcurrencyPolicies ¶ added in v1.0.63
func (r *Repository) ExportCredentialConcurrencyPolicies(ctx context.Context, root map[string]any) error
ExportCredentialConcurrencyPolicies adds all active limiter policies to an exchange config root.
func (*Repository) FailQuotaProbe ¶ added in v1.0.63
func (r *Repository) FailQuotaProbe(ctx context.Context, credentialID string, owner string, failure QuotaCollectionError, nextProbeAt time.Time) error
func (*Repository) FailQuotaProbeAt ¶ added in v1.0.63
func (r *Repository) FailQuotaProbeAt(ctx context.Context, credentialID string, owner string, failure QuotaCollectionError, nextProbeAt time.Time, now time.Time) error
FailQuotaProbeAt persists a failed probe using the supplied clock value.
func (*Repository) FailUserMailJob ¶ added in v1.0.63
func (r *Repository) FailUserMailJob(ctx context.Context, job *UserMailJobRecord, workerID string, errorCode string, now time.Time, retryAfter time.Duration, maxAttempts int) error
FailUserMailJob releases or terminates a failed claimed job.
func (*Repository) FenceHomeIncarnation ¶ added in v1.0.63
func (r *Repository) FenceHomeIncarnation(ctx context.Context, id HomeIncarnationID, reason string) error
FenceHomeIncarnation prevents an incarnation from accepting further heartbeats.
func (*Repository) ForceClaimEligibleQuotaProbe ¶ added in v1.0.63
func (r *Repository) ForceClaimEligibleQuotaProbe(ctx context.Context, credentialID string, owner string, now time.Time, leaseDuration time.Duration) (bool, error)
ForceClaimEligibleQuotaProbe claims an eligible credential while ignoring its snapshot freshness and retry schedule. An unexpired probe lease still wins.
func (*Repository) GetAuth ¶
func (r *Repository) GetAuth(ctx context.Context, uuid string) (*coreauth.Auth, *AuthRecord, error)
GetAuth returns an auth.
func (*Repository) GetBillingModelPrice ¶ added in v1.0.44
func (r *Repository) GetBillingModelPrice(ctx context.Context, id string) (*BillingModelPriceRecord, error)
func (*Repository) GetBillingModelPriceImportOperation ¶ added in v1.0.63
func (r *Repository) GetBillingModelPriceImportOperation(ctx context.Context, id string) (*BillingModelPriceImportOperation, error)
func (*Repository) GetBillingSettings ¶ added in v1.0.63
func (r *Repository) GetBillingSettings(ctx context.Context) (BillingSettings, error)
func (*Repository) GetBillingTierDiagnostics ¶ added in v1.0.63
func (r *Repository) GetBillingTierDiagnostics(ctx context.Context) (BillingTierDiagnostics, error)
func (*Repository) GetChannelGroup ¶ added in v1.0.44
func (r *Repository) GetChannelGroup(ctx context.Context, id uint) (*ChannelGroupRecord, error)
GetChannelGroup returns a channel group by ID.
func (*Repository) GetChannelGroupDetail ¶ added in v1.0.44
func (r *Repository) GetChannelGroupDetail(ctx context.Context, id uint) (*ChannelGroupDetailRecord, error)
GetChannelGroupDetail returns a channel group detail by ID.
func (*Repository) GetCredentialConcurrencyPolicy ¶ added in v1.0.63
func (r *Repository) GetCredentialConcurrencyPolicy(ctx context.Context, credentialID string) (CredentialConcurrencyPolicy, error)
GetCredentialConcurrencyPolicy returns one consistent policy version without applying admission behavior.
func (*Repository) GetModelGroup ¶ added in v1.0.44
func (r *Repository) GetModelGroup(ctx context.Context, id uint) (*ModelGroupRecord, error)
GetModelGroup returns a model group by ID.
func (*Repository) GetModelGroupDetail ¶ added in v1.0.44
func (r *Repository) GetModelGroupDetail(ctx context.Context, id uint) (*ModelGroupDetailRecord, error)
GetModelGroupDetail returns a model group detail by ID.
func (*Repository) GetOAuthSession ¶
func (r *Repository) GetOAuthSession(ctx context.Context, state string) (*OAuthSessionRecord, error)
GetOAuthSession returns an o auth session.
func (*Repository) GetPluginStoreAuth ¶ added in v1.0.63
func (r *Repository) GetPluginStoreAuth(ctx context.Context, id uint) (*PluginStoreAuthRecord, error)
func (*Repository) GetProxyPoolItem ¶ added in v1.0.44
func (r *Repository) GetProxyPoolItem(ctx context.Context, id string) (*ProxyPoolRecord, error)
func (*Repository) GetQuotaCredential ¶ added in v1.0.63
func (r *Repository) GetQuotaCredential(ctx context.Context, credentialID string, now time.Time) (*QuotaCredentialSnapshot, error)
func (*Repository) GetUsageObservabilityPayloadSummary ¶ added in v1.0.63
func (r *Repository) GetUsageObservabilityPayloadSummary(ctx context.Context, id string) (*UsageObservabilityPayloadSummary, error)
func (*Repository) GetUsageObservabilityRecord ¶ added in v1.0.63
func (r *Repository) GetUsageObservabilityRecord(ctx context.Context, id string) (*UsageObservabilityRecord, error)
func (*Repository) GetUser ¶ added in v1.0.44
func (r *Repository) GetUser(ctx context.Context, id uint) (*UserRecord, error)
GetUser returns a user by ID.
func (*Repository) GetUserByEmail ¶ added in v1.0.63
func (r *Repository) GetUserByEmail(ctx context.Context, email string) (*UserRecord, error)
GetUserByEmail returns the active user that owns a verified normalized email.
func (*Repository) GetUserByUsername ¶ added in v1.0.44
func (r *Repository) GetUserByUsername(ctx context.Context, username string) (*UserRecord, error)
GetUserByUsername returns a user by username.
func (*Repository) HeartbeatHomeIncarnation ¶ added in v1.0.63
func (r *Repository) HeartbeatHomeIncarnation(ctx context.Context, id HomeIncarnationID) error
HeartbeatHomeIncarnation refreshes an active incarnation with database time.
func (*Repository) ImportCredentialConcurrencyPolicies ¶ added in v1.0.63
func (r *Repository) ImportCredentialConcurrencyPolicies(ctx context.Context, root map[string]any) error
ImportCredentialConcurrencyPolicies imports the policy section in its own concurrency transaction.
func (*Repository) ImportCredentialConcurrencyPoliciesTx ¶ added in v1.0.63
func (r *Repository) ImportCredentialConcurrencyPoliciesTx(ctx context.Context, tx *gorm.DB, root map[string]any) error
ImportCredentialConcurrencyPoliciesTx imports policies within a caller-owned concurrency transaction.
func (*Repository) IngestInFlightFrame ¶ added in v1.0.63
func (r *Repository) IngestInFlightFrame(ctx context.Context, identity InFlightIngestIdentity, raw []byte, limits InFlightLimits) (InFlightIngestResult, error)
IngestInFlightFrame stages a multipart in-flight snapshot and publishes it only after all parts arrive.
func (*Repository) InvalidateUserSecurityTokenHash ¶ added in v1.0.63
func (r *Repository) InvalidateUserSecurityTokenHash(ctx context.Context, tokenHash string, now time.Time) error
InvalidateUserSecurityTokenHash invalidates one token after a failed delivery attempt.
func (*Repository) KVDel ¶ added in v1.0.44
KVDel deletes active keys and returns the active deletion count.
func (*Repository) KVMGet ¶ added in v1.0.44
func (r *Repository) KVMGet(ctx context.Context, keys []string) ([]KVGetResult, error)
KVMGet returns values in the same order as the requested keys.
func (*Repository) KVPurgeExpired ¶ added in v1.0.44
KVPurgeExpired deletes expired rows up to limit.
func (*Repository) KVSet ¶ added in v1.0.44
func (r *Repository) KVSet(ctx context.Context, key string, value []byte, ttl time.Duration, mode KVSetMode) (bool, error)
KVSet writes a value using the requested conditional mode.
func (*Repository) LifecycleConfig ¶ added in v1.0.63
func (r *Repository) LifecycleConfig(ctx context.Context) (config.CredentialConcurrencyConfig, error)
LifecycleConfig returns the configuration synthesized from the singleton row.
func (*Repository) ListAPIKeyEntries ¶ added in v1.0.44
func (r *Repository) ListAPIKeyEntries(ctx context.Context) ([]APIKeyEntry, error)
ListAPIKeyEntries returns API key rows with group bindings.
func (*Repository) ListAPIKeyRecordsForUser ¶ added in v1.0.44
func (r *Repository) ListAPIKeyRecordsForUser(ctx context.Context, userID uint) ([]APIKeyRecord, error)
ListAPIKeyRecordsForUser returns active API key rows owned by one user.
func (*Repository) ListAppLogs ¶ added in v1.0.44
func (r *Repository) ListAppLogs(ctx context.Context, opts AppLogQuery) (AppLogQueryResult, error)
ListAppLogs returns application log records from the database.
func (*Repository) ListAuthIndex ¶
func (r *Repository) ListAuthIndex(ctx context.Context) ([]AuthIndex, error)
ListAuthIndex returns an auth index.
func (*Repository) ListAuthsUnscoped ¶ added in v1.0.63
ListAuthsUnscoped lists active and soft-deleted credentials for identity checks.
func (*Repository) ListBillingBalanceRecords ¶ added in v1.0.44
func (r *Repository) ListBillingBalanceRecords(ctx context.Context, query BillingBalanceQuery) (BillingBalanceResult, error)
func (*Repository) ListBillingCharges ¶ added in v1.0.44
func (r *Repository) ListBillingCharges(ctx context.Context, query BillingChargeQuery) (BillingChargeResult, error)
func (*Repository) ListBillingModelPrices ¶ added in v1.0.44
func (r *Repository) ListBillingModelPrices(ctx context.Context, query BillingModelPriceQuery) ([]BillingModelPriceRecord, error)
func (*Repository) ListCPANodeSnapshots ¶ added in v1.0.63
func (r *Repository) ListCPANodeSnapshots(ctx context.Context, cutoff time.Time) ([]CPANodeRecord, error)
ListCPANodeSnapshots returns known CPA node snapshots, optionally bounded by last seen time.
func (*Repository) ListChannelGroupDetails ¶ added in v1.0.44
func (r *Repository) ListChannelGroupDetails(ctx context.Context, filter ChannelGroupDetailFilter) ([]ChannelGroupDetailRecord, error)
ListChannelGroupDetails returns channel group details.
func (*Repository) ListChannelGroups ¶ added in v1.0.44
func (r *Repository) ListChannelGroups(ctx context.Context) ([]ChannelGroupRecord, error)
ListChannelGroups returns channel groups.
func (*Repository) ListClusterNodes ¶ added in v1.0.63
func (r *Repository) ListClusterNodes(ctx context.Context, cutoff time.Time) ([]ClusterNodeRecord, error)
ListClusterNodes returns known Home cluster nodes, optionally bounded by last seen time.
func (*Repository) ListCredentialConcurrencyPolicies ¶ added in v1.0.63
func (r *Repository) ListCredentialConcurrencyPolicies(ctx context.Context) ([]CredentialConcurrencyPolicy, error)
ListCredentialConcurrencyPolicies returns all stored policy rows, including inactive rows retained for identity safety.
func (*Repository) ListLiveCPANodes ¶ added in v1.0.63
func (r *Repository) ListLiveCPANodes(ctx context.Context, cutoff time.Time) ([]CPANodeRecord, error)
ListLiveCPANodes returns live CPA node snapshots reported by active Home nodes.
func (*Repository) ListLiveClusterNodes ¶
func (r *Repository) ListLiveClusterNodes(ctx context.Context, cutoff time.Time) ([]ClusterNodeRecord, error)
ListLiveClusterNodes returns live cluster nodes.
func (*Repository) ListModelGroupDetails ¶ added in v1.0.44
func (r *Repository) ListModelGroupDetails(ctx context.Context, filter ModelGroupDetailFilter) ([]ModelGroupDetailRecord, error)
ListModelGroupDetails returns model group details.
func (*Repository) ListModelGroups ¶ added in v1.0.44
func (r *Repository) ListModelGroups(ctx context.Context) ([]ModelGroupRecord, error)
ListModelGroups returns model groups.
func (*Repository) ListPendingPluginTasks ¶ added in v1.0.44
func (r *Repository) ListPendingPluginTasks(ctx context.Context, nodeType string, nodeID string) ([]node.PluginTask, error)
ListPendingPluginTasks returns tasks that the given node has not acked yet.
func (*Repository) ListPendingQuiescence ¶ added in v1.0.63
func (r *Repository) ListPendingQuiescence(ctx context.Context, home HomeIncarnationID) ([]CPANodeQuiescenceRecord, error)
ListPendingQuiescence returns the exact pending fence rows owned by a Home incarnation.
func (*Repository) ListPluginStatuses ¶ added in v1.0.44
func (r *Repository) ListPluginStatuses(ctx context.Context, nodeType string) ([]node.PluginTaskStatus, error)
ListPluginStatuses returns the latest plugin task statuses grouped by node and report.
func (*Repository) ListPluginStoreAuth ¶ added in v1.0.63
func (r *Repository) ListPluginStoreAuth(ctx context.Context) ([]PluginStoreAuthRecord, error)
func (*Repository) ListProxyPoolItems ¶ added in v1.0.44
func (r *Repository) ListProxyPoolItems(ctx context.Context) ([]ProxyPoolRecord, error)
func (*Repository) ListQuotaCredentials ¶ added in v1.0.63
func (r *Repository) ListQuotaCredentials(ctx context.Context, query QuotaListQuery) (QuotaListResult, error)
func (*Repository) ListUsageObservabilityAggregates ¶ added in v1.0.63
func (r *Repository) ListUsageObservabilityAggregates(ctx context.Context, query UsageObservabilityAggregateQuery) (UsageObservabilityAggregateResult, error)
func (*Repository) ListUsageObservabilityRecords ¶ added in v1.0.63
func (r *Repository) ListUsageObservabilityRecords(ctx context.Context, query UsageObservabilityRecordQuery) (UsageObservabilityRecordListResult, error)
func (*Repository) ListUsers ¶ added in v1.0.44
func (r *Repository) ListUsers(ctx context.Context) ([]UserRecord, error)
ListUsers returns users.
func (*Repository) LiveClusterNodeByIPAndSecret ¶
func (r *Repository) LiveClusterNodeByIPAndSecret(ctx context.Context, ip string, secret string, cutoff time.Time) (*ClusterNodeRecord, error)
LiveClusterNodeByIPAndSecret handles a live cluster node by ip and secret.
func (*Repository) LoadConfigAsRuntimeConfig ¶
func (r *Repository) LoadConfigAsRuntimeConfig(ctx context.Context) (*appconfig.Config, []byte, error)
LoadConfigAsRuntimeConfig loads a config as runtime config.
func (*Repository) LoadConfigSnapshot ¶
func (r *Repository) LoadConfigSnapshot(ctx context.Context) (map[string]json.RawMessage, error)
LoadConfigSnapshot loads a config snapshot.
func (*Repository) LockActiveConcurrencyLifetimeTx ¶ added in v1.0.63
func (r *Repository) LockActiveConcurrencyLifetimeTx(ctx context.Context, tx *gorm.DB, lifetime ConnectionLifetime) error
LockActiveConcurrencyLifetimeTx locks and verifies the active membership and Home that accepted a command.
func (*Repository) MarkProxyPoolTestResult ¶ added in v1.0.44
func (r *Repository) MarkProxyPoolTestResult(ctx context.Context, id string, result string, testedAt time.Time) (*ProxyPoolRecord, error)
func (*Repository) MaxEventID ¶
func (r *Repository) MaxEventID(ctx context.Context) (int64, error)
MaxEventID handles a max event id.
func (*Repository) MergeOAuthSessionData ¶
func (r *Repository) MergeOAuthSessionData(ctx context.Context, state string, values map[string]any) error
MergeOAuthSessionData merges an o auth session data.
func (*Repository) MutateAuth ¶ added in v1.0.63
func (r *Repository) MutateAuth(ctx context.Context, uuid string, op string, mutate func(auth *coreauth.Auth) bool) (*coreauth.Auth, *AuthRecord, bool, error)
MutateAuth loads an auth row under a write lock, applies mutate to the decoded auth, and persists the result in the same transaction when mutate reports a change. Concurrent mutations from other Home nodes serialize on the row lock, which keeps read-modify-write transitions such as quota backoff escalation atomic across the cluster. The returned auth and record reflect the post-transaction row state.
func (*Repository) PatchAuthAndConcurrency ¶ added in v1.0.63
func (r *Repository) PatchAuthAndConcurrency(ctx context.Context, request AuthConcurrencyPatchRequest) error
PatchAuthAndConcurrency atomically applies auth metadata and limiter policy changes.
func (*Repository) PatchCredentialConcurrencyPolicy ¶ added in v1.0.63
func (r *Repository) PatchCredentialConcurrencyPolicy(ctx context.Context, credentialID string, patch ConcurrencyPolicyPatch, expectedVersion *int64) (CredentialConcurrencyPolicy, error)
PatchCredentialConcurrencyPolicy atomically validates and replaces policy fields for a credential.
func (*Repository) PatchProxyPoolItem ¶ added in v1.0.44
func (r *Repository) PatchProxyPoolItem(ctx context.Context, id string, patch ProxyPoolPatch) (*ProxyPoolRecord, error)
func (*Repository) PluginStoreAuthRevision ¶ added in v1.0.63
func (r *Repository) PluginStoreAuthRevision(ctx context.Context) (int64, error)
func (*Repository) PurgeExpiredUserSecurity ¶ added in v1.0.63
func (r *Repository) PurgeExpiredUserSecurity(ctx context.Context, now time.Time, retention time.Duration) error
PurgeExpiredUserSecurity removes old terminal security records.
func (*Repository) ReadConcurrencyState ¶ added in v1.0.63
func (r *Repository) ReadConcurrencyState(ctx context.Context) ([]CredentialConcurrencyState, error)
ReadConcurrencyState returns policy and admitted counter state without relying on CPA observations.
func (*Repository) ReadInFlightObservation ¶ added in v1.0.63
func (r *Repository) ReadInFlightObservation(ctx context.Context, staleAfter time.Duration) (InFlightObservationReadModel, error)
ReadInFlightObservation returns only snapshots belonging to current active memberships.
func (*Repository) ReadInFlightSnapshotCursorPage ¶ added in v1.0.63
func (r *Repository) ReadInFlightSnapshotCursorPage(ctx context.Context, cursor string, credentialID string, model string, offset int, limit int) (InFlightSnapshotCursor, error)
ReadInFlightSnapshotCursorPage returns one page from an unexpired immutable cursor without loading the cursor's complete item set.
func (*Repository) ReconcileProviderAuths ¶ added in v1.0.63
func (r *Repository) ReconcileProviderAuths(ctx context.Context, key string, next []*coreauth.Auth, checker CredentialReferenceChecker) error
ReconcileProviderAuths atomically updates one provider config credential set.
func (*Repository) RecordParticipation ¶ added in v1.0.63
func (r *Repository) RecordParticipation(ctx context.Context, lifetime ConnectionLifetime) error
RecordParticipation records a Home's connection to an active membership lifetime.
func (*Repository) RecoverStaleQuiescence ¶ added in v1.0.63
func (r *Repository) RecoverStaleQuiescence(ctx context.Context) error
RecoverStaleQuiescence fences eligible unavailable Homes and completes affected cancellations.
func (*Repository) RefreshCPALiveness ¶ added in v1.0.63
func (r *Repository) RefreshCPALiveness(ctx context.Context, lifetime ConnectionLifetime) error
RefreshCPALiveness records a subscription pong only while its Home and membership lifetime remain active.
func (*Repository) RegisterHomeIncarnation ¶ added in v1.0.63
func (r *Repository) RegisterHomeIncarnation(ctx context.Context, ip string, port int, capabilities []string) (HomeIncarnationID, error)
RegisterHomeIncarnation records a new active Home incarnation using database time.
func (*Repository) RenewUserMailJobClaim ¶ added in v1.0.63
func (r *Repository) RenewUserMailJobClaim(ctx context.Context, jobID uint, workerID string, now time.Time, lease time.Duration) error
RenewUserMailJobClaim extends an active worker lease before network delivery.
func (*Repository) ReplaceAPIKeyEntries ¶ added in v1.0.44
func (r *Repository) ReplaceAPIKeyEntries(ctx context.Context, entries []APIKeyEntryUpdate) (APIKeyUpsertStats, error)
ReplaceAPIKeyEntries replaces active API key rows and updates explicit channel bindings.
func (*Repository) ReplaceCPANodeSnapshot ¶ added in v1.0.63
func (r *Repository) ReplaceCPANodeSnapshot(ctx context.Context, homeIP string, homePort int, nodes []node.Node, seenAt time.Time) error
ReplaceCPANodeSnapshot replaces the active CPA connection snapshot owned by one Home node.
func (*Repository) ReplaceCPANodeSnapshotForIncarnation ¶ added in v1.0.63
func (r *Repository) ReplaceCPANodeSnapshotForIncarnation(ctx context.Context, home HomeIncarnationID, nodes []node.Node, seenAt time.Time) error
ReplaceCPANodeSnapshotForIncarnation writes a snapshot only for the active exact Home process incarnation.
func (*Repository) ReplaceConfigSnapshot ¶
ReplaceConfigSnapshot handles a replace config snapshot.
func (*Repository) ReplaceConfigSnapshotAndCreatePluginTask ¶ added in v1.0.44
func (r *Repository) ReplaceConfigSnapshotAndCreatePluginTask(ctx context.Context, values map[string]any, task node.PluginTask) (node.PluginTask, error)
ReplaceConfigSnapshotAndCreatePluginTask replaces config and creates a plugin task atomically.
func (*Repository) ReplaceConfigSnapshotWithLifecycleConfig ¶ added in v1.0.63
func (r *Repository) ReplaceConfigSnapshotWithLifecycleConfig(ctx context.Context, nodeHeartbeatTimeout time.Duration, values map[string]any) error
ReplaceConfigSnapshotWithLifecycleConfig replaces a snapshot after applying its lifecycle configuration.
func (*Repository) ReplaceConfigSnapshotWithLifecycleConfigAndCreatePluginTask ¶ added in v1.0.63
func (r *Repository) ReplaceConfigSnapshotWithLifecycleConfigAndCreatePluginTask(ctx context.Context, nodeHeartbeatTimeout time.Duration, values map[string]any, task node.PluginTask) (node.PluginTask, error)
ReplaceConfigSnapshotWithLifecycleConfigAndCreatePluginTask applies lifecycle config before replacing a snapshot and creating a task.
func (*Repository) ReplacePluginStatus ¶ added in v1.0.44
func (r *Repository) ReplacePluginStatus(ctx context.Context, nodeType string, status node.PluginTaskStatus) error
ReplacePluginStatus stores the latest plugin task status for one node.
func (*Repository) ReplaceUserSecurityToken ¶ added in v1.0.63
func (r *Repository) ReplaceUserSecurityToken(ctx context.Context, record UserSecurityTokenRecord) error
ReplaceUserSecurityToken invalidates outstanding tokens for the same purpose and stores a new hash.
func (*Repository) ReplaceUserSecurityTokenForMailJob ¶ added in v1.0.63
func (r *Repository) ReplaceUserSecurityTokenForMailJob(ctx context.Context, jobID uint, workerID string, record UserSecurityTokenRecord) error
ReplaceUserSecurityTokenForMailJob stores a token only while the originating mail job is still claimed by the worker. A concurrent resend or email change supersedes the job and prevents an older worker from replacing the newer token.
func (*Repository) RequireActiveCPAMembership ¶ added in v1.0.63
func (r *Repository) RequireActiveCPAMembership(ctx context.Context, tx *gorm.DB, identity InFlightIngestIdentity) (CPANodeMembershipRecord, error)
RequireActiveCPAMembership locks and verifies the membership lifetime that owns an in-flight frame.
func (*Repository) ResetUserPeriodLimits ¶ added in v1.0.63
func (r *Repository) ResetUserPeriodLimits(ctx context.Context, userID uint, windows []string, mode string, now time.Time) (UserPeriodLimitResetResult, error)
ResetUserPeriodLimits soft-resets period counters for the selected windows.
func (*Repository) RetireHomeIncarnation ¶ added in v1.0.63
func (r *Repository) RetireHomeIncarnation(ctx context.Context, id HomeIncarnationID) error
RetireHomeIncarnation permanently retires an active incarnation.
func (*Repository) RetireProviderAuth ¶ added in v1.0.63
func (r *Repository) RetireProviderAuth(ctx context.Context, credentialID string) error
RetireProviderAuth soft-deletes a provider credential without removing related state.
func (*Repository) RunUsageCacheReadBackfillBatch ¶ added in v1.0.63
func (r *Repository) RunUsageCacheReadBackfillBatch(ctx context.Context) (UsageCacheReadBackfillResult, error)
RunUsageCacheReadBackfillBatch advances the historical cache-read migration without holding the schema migration transaction open. CPA versions before v7.2.67 wrote cache reads to cached_tokens; new ingress and read paths remain compatible while this resumable maintenance task catches up. It updates usage dimensions only and never rewrites immutable billing charges or balances.
func (*Repository) RunUsageDerivedColumnBackfillBatch ¶ added in v1.0.63
func (r *Repository) RunUsageDerivedColumnBackfillBatch(ctx context.Context) (UsageDerivedColumnBackfillResult, error)
RunUsageDerivedColumnBackfillBatch advances the historical usage metadata migration without blocking startup on a full payload scan.
func (*Repository) RunUsageTokenAccountingBackfillBatch ¶ added in v1.0.63
func (r *Repository) RunUsageTokenAccountingBackfillBatch(ctx context.Context) (UsageTokenAccountingBackfillResult, error)
func (*Repository) SetOAuthSessionError ¶
SetOAuthSessionError sets an o auth session error.
func (*Repository) SignClientCertificateRequest ¶ added in v1.0.44
func (r *Repository) SignClientCertificateRequest(ctx context.Context, certificateID string, enrollmentSecret string, csrPEM []byte) ([]byte, []byte, error)
SignClientCertificateRequest signs a client CSR exactly once and returns the client certificate plus CA.
func (*Repository) SignClientCertificateRequestJSON ¶ added in v1.0.44
func (r *Repository) SignClientCertificateRequestJSON(ctx context.Context, certificateID string, enrollmentSecret string, csrPEM []byte) ([]byte, error)
SignClientCertificateRequestJSON signs a CSR and returns the RESP JSON payload.
func (*Repository) SoftDeleteAuth ¶
func (r *Repository) SoftDeleteAuth(ctx context.Context, uuid string) error
SoftDeleteAuth handles a soft delete auth.
func (*Repository) SubscribeMembership ¶ added in v1.0.63
func (r *Repository) SubscribeMembership(ctx context.Context, request SubscribeMembershipRequest) (CPANodeMembershipRecord, error)
SubscribeMembership creates a new active membership for a certificate fingerprint.
func (*Repository) SumUserChargeAmountSince ¶ added in v1.0.63
func (r *Repository) SumUserChargeAmountSince(ctx context.Context, userID uint, since time.Time) (float64, error)
SumUserChargeAmountSince sums billing_charge.amount for a user since the given timestamp.
func (*Repository) SupersedeUserMailJob ¶ added in v1.0.63
func (r *Repository) SupersedeUserMailJob(ctx context.Context, jobID uint, workerID string, now time.Time) error
SupersedeUserMailJob marks a claimed job obsolete.
func (*Repository) UpdateAPIKey ¶ added in v1.0.63
func (r *Repository) UpdateAPIKey(ctx context.Context, selector APIKeySelector, update APIKeyAdminUpdate) (*APIKeyRecord, error)
UpdateAPIKey updates one API key selected by stable ID or a legacy selector.
func (*Repository) UpdateAPIKeyBindings ¶ added in v1.0.44
func (r *Repository) UpdateAPIKeyBindings(ctx context.Context, apiKey string, userID *uint, channels *[]uint, modelGroups *[]uint) (*APIKeyRecord, error)
UpdateAPIKeyBindings updates user and group bindings for one API key.
func (*Repository) UpdateAPIKeyChannels ¶ added in v1.0.44
func (r *Repository) UpdateAPIKeyChannels(ctx context.Context, apiKey string, channels []uint) (*APIKeyRecord, error)
UpdateAPIKeyChannels updates channel bindings for one API key.
func (*Repository) UpdateAPIKeyForUser ¶ added in v1.0.44
func (r *Repository) UpdateAPIKeyForUser(ctx context.Context, userID uint, id uint, apiKey string, update APIKeyUserUpdate) (*APIKeyRecord, error)
UpdateAPIKeyForUser updates one API key owned by one user.
func (*Repository) UpdateBillingModelPrice ¶ added in v1.0.44
func (r *Repository) UpdateBillingModelPrice(ctx context.Context, id string, patch BillingModelPricePatch) (*BillingModelPriceRecord, error)
func (*Repository) UpdateBillingSettings ¶ added in v1.0.63
func (r *Repository) UpdateBillingSettings(ctx context.Context, patch BillingSettingsPatch) (BillingSettings, error)
func (*Repository) UpdateChannelGroup ¶ added in v1.0.44
func (r *Repository) UpdateChannelGroup(ctx context.Context, id uint, update ChannelGroupUpdate) (*ChannelGroupRecord, error)
UpdateChannelGroup updates a channel group.
func (*Repository) UpdateChannelGroupDetail ¶ added in v1.0.44
func (r *Repository) UpdateChannelGroupDetail(ctx context.Context, id uint, update ChannelGroupDetailUpdate) (*ChannelGroupDetailRecord, error)
UpdateChannelGroupDetail updates a channel group detail.
func (*Repository) UpdateLifecycleConfig ¶ added in v1.0.63
func (r *Repository) UpdateLifecycleConfig(ctx context.Context, nodeHeartbeatTimeout time.Duration, next config.CredentialConcurrencyConfig) (int64, error)
UpdateLifecycleConfig validates and persists a lifecycle configuration revision.
func (*Repository) UpdateModelGroup ¶ added in v1.0.44
func (r *Repository) UpdateModelGroup(ctx context.Context, id uint, update ModelGroupUpdate) (*ModelGroupRecord, error)
UpdateModelGroup updates a model group.
func (*Repository) UpdateModelGroupDetail ¶ added in v1.0.44
func (r *Repository) UpdateModelGroupDetail(ctx context.Context, id uint, update ModelGroupDetailUpdate) (*ModelGroupDetailRecord, error)
UpdateModelGroupDetail updates a model group detail.
func (*Repository) UpdatePluginStoreAuth ¶ added in v1.0.63
func (r *Repository) UpdatePluginStoreAuth(ctx context.Context, record *PluginStoreAuthRecord) error
func (*Repository) UpdateProxyPoolItem ¶ added in v1.0.44
func (r *Repository) UpdateProxyPoolItem(ctx context.Context, id string, update ProxyPoolUpdate) (*ProxyPoolRecord, error)
func (*Repository) UpdateUser ¶ added in v1.0.44
func (r *Repository) UpdateUser(ctx context.Context, id uint, update UserUpdate) (*UserRecord, error)
UpdateUser updates a user.
func (*Repository) UpsertAPIKeys ¶ added in v1.0.44
func (r *Repository) UpsertAPIKeys(ctx context.Context, keys []string) (APIKeyUpsertStats, error)
UpsertAPIKeys inserts or restores API keys without deleting keys missing from the input.
func (*Repository) UpsertAuth ¶
func (r *Repository) UpsertAuth(ctx context.Context, auth *coreauth.Auth, op string) (*AuthRecord, error)
UpsertAuth inserts or updates an auth.
func (*Repository) UpsertAuthPreservingDisabled ¶ added in v1.0.63
func (r *Repository) UpsertAuthPreservingDisabled(ctx context.Context, auth *coreauth.Auth, op string) (*AuthRecord, error)
UpsertAuthPreservingDisabled inserts or updates an auth without re-enabling an existing disabled record.
func (*Repository) UpsertAuthWithResult ¶ added in v1.0.44
func (r *Repository) UpsertAuthWithResult(ctx context.Context, auth *coreauth.Auth, op string) (*AuthRecord, UpsertResult, error)
UpsertAuthWithResult inserts or updates an auth and reports the mutation result.
func (*Repository) UpsertConfigValue ¶
UpsertConfigValue inserts or updates a config value.
func (*Repository) UpsertConfigValueWithResult ¶ added in v1.0.44
func (r *Repository) UpsertConfigValueWithResult(ctx context.Context, key string, value any) (UpsertResult, error)
UpsertConfigValueWithResult inserts or updates a config value and reports the mutation result.
func (*Repository) UpsertOAuthSession ¶
func (r *Repository) UpsertOAuthSession(ctx context.Context, record *OAuthSessionRecord) error
UpsertOAuthSession inserts or updates an o auth session.
func (*Repository) UpsertQuotaSnapshot ¶ added in v1.0.63
func (r *Repository) UpsertQuotaSnapshot(ctx context.Context, input QuotaSnapshotWrite) (bool, error)
func (*Repository) UsageObservabilityFilterOptions ¶ added in v1.0.63
func (r *Repository) UsageObservabilityFilterOptions(ctx context.Context, query UsageObservabilityRecordQuery) (UsageObservabilityFilterOptions, error)
func (*Repository) UsageObservabilityHealthDetails ¶ added in v1.0.63
func (r *Repository) UsageObservabilityHealthDetails(ctx context.Context, query UsageObservabilityRecordQuery, subject string) (map[string]UsageObservabilityHealthDetail, error)
func (*Repository) UsageObservabilityOverview ¶ added in v1.0.63
func (r *Repository) UsageObservabilityOverview(ctx context.Context, query UsageObservabilityOverviewQuery) (UsageObservabilityOverview, error)
func (*Repository) UsageObservabilityRealtime ¶ added in v1.0.63
func (r *Repository) UsageObservabilityRealtime(ctx context.Context, query UsageObservabilityRealtimeQuery) (UsageObservabilityRealtimeSnapshot, error)
func (*Repository) UsageTokenBreakdownV2Ready ¶ added in v1.0.63
func (r *Repository) UsageTokenBreakdownV2Ready(ctx context.Context) (bool, error)
UsageTokenBreakdownV2Ready reports whether every persisted usage row has a canonical v2 breakdown. The indexed existence check remains cheap while the resumable backfill is still draining historical rows.
func (*Repository) ValidateAPIKey ¶ added in v1.0.44
ValidateAPIKey reports whether an API key exists as an active record.
func (*Repository) WithAuthRefreshLock ¶
func (r *Repository) WithAuthRefreshLock(ctx context.Context, uuid string, fn func(tx *Repository, auth *coreauth.Auth) (*coreauth.Auth, error)) (*coreauth.Auth, error)
WithAuthRefreshLock applies the auth refresh lock option.
func (*Repository) WithConcurrencyActivationGate ¶ added in v1.0.63
func (r *Repository) WithConcurrencyActivationGate(ctx context.Context, fn func(*gorm.DB, *ConcurrencyActivationGateRecord) error) error
WithConcurrencyActivationGate runs fn while holding the singleton activation gate lock.
type RuntimeAdapter ¶
type RuntimeAdapter struct {
// contains filtered or unexported fields
}
func NewRuntimeAdapter ¶
func NewRuntimeAdapter(repo *Repository, homeIP string, homePort ...int) *RuntimeAdapter
NewRuntimeAdapter creates a new runtime adapter.
func (*RuntimeAdapter) AllowedAuthIDsForAPIKey ¶ added in v1.0.44
func (a *RuntimeAdapter) AllowedAuthIDsForAPIKey(ctx context.Context, apiKey string) ([]string, error)
AllowedAuthIDsForAPIKey returns auth IDs allowed by API-key channel bindings.
func (*RuntimeAdapter) AllowedDispatchIDsForAPIKey ¶ added in v1.0.44
func (a *RuntimeAdapter) AllowedDispatchIDsForAPIKey(ctx context.Context, apiKey string) ([]string, []string, error)
AllowedDispatchIDsForAPIKey returns auth and model IDs allowed by API-key bindings.
func (*RuntimeAdapter) AllowedDispatchIDsForAPIKeyModel ¶ added in v1.0.63
func (a *RuntimeAdapter) AllowedDispatchIDsForAPIKeyModel(ctx context.Context, apiKey string, modelID string) ([]string, []string, error)
AllowedDispatchIDsForAPIKeyModel returns auth and model IDs after applying model-specific channel bindings.
func (*RuntimeAdapter) AllowedModelIDsForAPIKey ¶ added in v1.0.44
func (a *RuntimeAdapter) AllowedModelIDsForAPIKey(ctx context.Context, apiKey string) ([]string, error)
AllowedModelIDsForAPIKey returns model IDs allowed by API-key model group bindings.
func (*RuntimeAdapter) ApplyEvent ¶
func (a *RuntimeAdapter) ApplyEvent(ctx context.Context, event ClusterEventRecord) error
ApplyEvent updates apply event.
func (*RuntimeAdapter) Delete ¶
func (a *RuntimeAdapter) Delete(ctx context.Context, id string) error
Delete handles delete.
func (*RuntimeAdapter) Enabled ¶
func (a *RuntimeAdapter) Enabled() bool
Enabled handles an enabled.
func (*RuntimeAdapter) GetFullAuth ¶
GetFullAuth returns a full auth.
func (*RuntimeAdapter) InvalidateFullAuth ¶
func (a *RuntimeAdapter) InvalidateFullAuth(uuid string)
InvalidateFullAuth invalidates a full auth.
func (*RuntimeAdapter) KVMGet ¶ added in v1.0.44
func (a *RuntimeAdapter) KVMGet(ctx context.Context, keys []string) ([]home.KVGetResult, error)
KVMGet returns KV values in request order.
func (*RuntimeAdapter) KVPurgeExpired ¶ added in v1.0.44
func (a *RuntimeAdapter) KVPurgeExpired(ctx context.Context, now time.Time, limit int) (int64, error)
KVPurgeExpired deletes expired KV rows.
func (*RuntimeAdapter) KVSet ¶ added in v1.0.44
func (a *RuntimeAdapter) KVSet(ctx context.Context, key string, value []byte, ttl time.Duration, mode string) (bool, error)
KVSet writes a KV value.
func (*RuntimeAdapter) ListMinimalAuths ¶
func (a *RuntimeAdapter) ListMinimalAuths() []*coreauth.Auth
ListMinimalAuths returns a minimal auths.
func (*RuntimeAdapter) ListPendingPluginTasks ¶ added in v1.0.44
func (a *RuntimeAdapter) ListPendingPluginTasks(ctx context.Context, nodeType string, nodeID string) ([]node.PluginTask, error)
ListPendingPluginTasks returns plugin tasks that the node has not acked yet.
func (*RuntimeAdapter) LoadAuthIndex ¶
func (a *RuntimeAdapter) LoadAuthIndex(ctx context.Context) error
LoadAuthIndex loads an auth index.
func (*RuntimeAdapter) LoadConfigYAML ¶
func (a *RuntimeAdapter) LoadConfigYAML(ctx context.Context) ([]byte, error)
LoadConfigYAML loads a config yaml.
func (*RuntimeAdapter) LoadIndex ¶
func (a *RuntimeAdapter) LoadIndex(ctx context.Context) error
LoadIndex loads an index.
func (*RuntimeAdapter) MutateAuthState ¶ added in v1.0.63
func (a *RuntimeAdapter) MutateAuthState(ctx context.Context, id string, mutate func(auth *coreauth.Auth) bool) (*coreauth.Auth, error)
MutateAuthState implements coreauth.StateMutator. It applies mutate to the persisted auth row under the cluster write lock so availability transitions stay atomic across Home nodes, then refreshes the local index and cache.
func (*RuntimeAdapter) RefreshAuthIndex ¶
func (a *RuntimeAdapter) RefreshAuthIndex(ctx context.Context, uuid string) error
RefreshAuthIndex refreshes refresh auth index.
func (*RuntimeAdapter) RemoveAuthIndex ¶
func (a *RuntimeAdapter) RemoveAuthIndex(uuid string)
RemoveAuthIndex removes an auth index.
func (*RuntimeAdapter) ReplacePluginStatus ¶ added in v1.0.44
func (a *RuntimeAdapter) ReplacePluginStatus(ctx context.Context, nodeType string, status node.PluginTaskStatus) error
ReplacePluginStatus stores the latest plugin status report for a node.
func (*RuntimeAdapter) SetHomePort ¶ added in v1.0.63
func (a *RuntimeAdapter) SetHomePort(port int)
SetHomePort updates the advertised Home port used for future usage records.
func (*RuntimeAdapter) StoreAppLogPayload ¶ added in v1.0.44
func (a *RuntimeAdapter) StoreAppLogPayload(ctx context.Context, clientIP string, payload string) error
StoreAppLogPayload stores a CPA app log payload.
func (*RuntimeAdapter) StoreUsagePayload ¶
func (a *RuntimeAdapter) StoreUsagePayload(ctx context.Context, payload string) error
StoreUsagePayload stores an usage payload.
func (*RuntimeAdapter) ValidateAPIKey ¶ added in v1.0.44
ValidateAPIKey reports whether an API key is active in the cluster database.
type SQLiteConfig ¶ added in v1.0.44
type SQLiteConfig struct {
Path string `yaml:"path"`
}
func (SQLiteConfig) Configured ¶ added in v1.0.44
func (c SQLiteConfig) Configured() bool
Configured reports whether SQLite has cluster database settings.
type StartupRecovery ¶ added in v1.0.63
type StartupRecovery func(context.Context, HomeIncarnationID) error
StartupRecovery completes pending startup work before listeners accept traffic.
type SubscribeMembershipRequest ¶ added in v1.0.63
type SubscribeMembershipRequest struct {
Fingerprint string
NodeID string
Home HomeIncarnationID
ProtocolVersion int
LifecycleConfigRevision int64
}
SubscribeMembershipRequest contains the subscription identity supplied by a CPA node.
type UpsertResult ¶ added in v1.0.44
type UpsertResult string
const ( UpsertResultCreated UpsertResult = "created" UpsertResultUpdated UpsertResult = "updated" UpsertResultUnchanged UpsertResult = "unchanged" UpsertResultRestored UpsertResult = "restored" )
type UsageCacheReadBackfillResult ¶ added in v1.0.63
UsageCacheReadBackfillResult describes one bounded historical usage backfill batch.
type UsageDerivedColumnBackfillResult ¶ added in v1.0.63
UsageDerivedColumnBackfillResult describes one bounded historical usage metadata backfill batch.
type UsageObservabilityActivityPoint ¶ added in v1.0.63
type UsageObservabilityAggregateItem ¶ added in v1.0.63
type UsageObservabilityAggregateItem struct {
ID string
Label string
Metadata map[string]any
RequestCount int64
SuccessCount int64
FailedCount int64
SuccessRate float64
ErrorRate float64
InputTokens int64
OutputTokens int64
ReasoningTokens int64
CachedTokens int64
CacheReadTokens int64
CacheCreationTokens int64
CacheRate float64
TotalTokens int64
TokenBreakdown UsageTokenBreakdown
TotalAmount *float64
Currency string
AvgLatencyMS *float64
P95LatencyMS *float64
LastUsedAt *time.Time
}
type UsageObservabilityAggregateQuery ¶ added in v1.0.63
type UsageObservabilityAggregateResult ¶ added in v1.0.63
type UsageObservabilityAggregateResult struct {
Items []UsageObservabilityAggregateItem
Total int64
}
type UsageObservabilityBilling ¶ added in v1.0.63
type UsageObservabilityClient ¶ added in v1.0.63
type UsageObservabilityCostBreakdownItem ¶ added in v1.0.63
type UsageObservabilityCredential ¶ added in v1.0.63
type UsageObservabilityError ¶ added in v1.0.63
type UsageObservabilityFilterOptions ¶ added in v1.0.63
type UsageObservabilityHealthDetail ¶ added in v1.0.63
type UsageObservabilityLatencyDistributionBucket ¶ added in v1.0.63
type UsageObservabilityLiveSummary ¶ added in v1.0.63
type UsageObservabilityOverview ¶ added in v1.0.63
type UsageObservabilityOverview struct {
Range UsageObservabilityOverviewRange
Live UsageObservabilityLiveSummary
Totals UsageObservabilityTotals
Trend []UsageObservabilityTrendPoint
CostBreakdown []UsageObservabilityCostBreakdownItem
ModelEfficiency []UsageObservabilityAggregateItem
Top UsageObservabilityTopGroups
Activity []UsageObservabilityActivityPoint
}
type UsageObservabilityOverviewQuery ¶ added in v1.0.63
type UsageObservabilityOverviewRange ¶ added in v1.0.63
type UsageObservabilityPayloadSummary ¶ added in v1.0.63
type UsageObservabilityPerformance ¶ added in v1.0.63
type UsageObservabilityRealtimeQuery ¶ added in v1.0.63
type UsageObservabilityRealtimeSnapshot ¶ added in v1.0.63
type UsageObservabilityRealtimeSnapshot struct {
Velocity []UsageObservabilityRealtimeVelocityPoint
LatencyDistribution []UsageObservabilityLatencyDistributionBucket
CurrentUsage []UsageObservabilityAggregateItem
}
type UsageObservabilityRealtimeVelocityPoint ¶ added in v1.0.63
type UsageObservabilityRecord ¶ added in v1.0.63
type UsageObservabilityRecord struct {
ID string
UsageID uint
Timestamp time.Time
RequestID string
UpstreamRequestID string
EventType string
Status string
Failed bool
StatusCode int
UpstreamStatusCode int
Source string
Provider string
Model string
OriginalModel string
Endpoint string
ServiceTier string
ReasoningEffort string
ExecutorType string
Tokens UsageObservabilityTokens
Performance UsageObservabilityPerformance
Client UsageObservabilityClient
Credential UsageObservabilityCredential
Billing UsageObservabilityBilling
Runtime UsageObservabilityRuntime
Error *UsageObservabilityError
}
type UsageObservabilityRecordListResult ¶ added in v1.0.63
type UsageObservabilityRecordListResult struct {
Records []UsageObservabilityRecord
Total int64
}
type UsageObservabilityRecordQuery ¶ added in v1.0.63
type UsageObservabilityRecordQuery struct {
From *time.Time
To *time.Time
Provider string
Model string
HomeIP string
Endpoint string
CredentialType string
Status string
StatusCode *int
RequestID string
User string
UserID *uint
ClientKey string
ClientKeyID *uint
CredentialID string
AuthIndex string
ExecutorType string
EventType string
CPANode string
MinLatencyMS *int64
MaxLatencyMS *int64
MinAmount *float64
MaxAmount *float64
Search string
RequestLogSearch string
Limit int
Offset int
Sort string
MaxLimit int
}
type UsageObservabilityRuntime ¶ added in v1.0.63
type UsageObservabilityTokens ¶ added in v1.0.63
type UsageObservabilityTopGroups ¶ added in v1.0.63
type UsageObservabilityTopGroups struct {
Users []UsageObservabilityAggregateItem
ClientKeys []UsageObservabilityAggregateItem
Credentials []UsageObservabilityAggregateItem
Providers []UsageObservabilityAggregateItem
Models []UsageObservabilityAggregateItem
Endpoints []UsageObservabilityAggregateItem
Errors []UsageObservabilityAggregateItem
}
type UsageObservabilityTotals ¶ added in v1.0.63
type UsageObservabilityTotals struct {
RequestCount int64
SuccessCount int64
FailedCount int64
ErrorRate float64
SuccessRate float64
InputTokens int64
OutputTokens int64
ReasoningTokens int64
CachedTokens int64
CacheReadTokens int64
CacheCreationTokens int64
TotalTokens int64
TokenBreakdown UsageTokenBreakdown
TotalAmount *float64
Currency string
BlendedCostPer1M *float64
AvgLatencyMS *float64
P50LatencyMS *float64
P95LatencyMS *float64
AvgTTFTMS *float64
ActiveUserCount int64
ActiveClientKeyCount int64
ActiveCredentialCount int64
ActiveModelCount int64
}
type UsageObservabilityTrendPoint ¶ added in v1.0.63
type UsageObservabilityTrendPoint struct {
BucketStart time.Time
BucketEnd time.Time
RequestCount int64
SuccessCount int64
FailedCount int64
InputTokens int64
OutputTokens int64
ReasoningTokens int64
CachedTokens int64
CacheReadTokens int64
CacheCreationTokens int64
TotalTokens int64
TokenBreakdown UsageTokenBreakdown
TotalAmount *float64
AvgLatencyMS *float64
P95LatencyMS *float64
}
type UsageRecord ¶
type UsageRecord struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement;index:idx_usage_time_order,priority:2"`
Timestamp time.Time `` /* 565-byte string literal not displayed */
LatencyMS int64 `gorm:"column:latency_ms;not null;default:0"`
TTFTMS int64 `gorm:"column:ttft_ms;not null;default:0"`
Source string `gorm:"column:source;index:idx_usage_source;index:idx_usage_source_time,priority:1"`
AuthIndex string `gorm:"column:auth_index;index:idx_usage_auth_index;index:idx_usage_auth_time,priority:1"`
InputTokens int64 `gorm:"column:input_tokens;not null;default:0"`
OutputTokens int64 `gorm:"column:output_tokens;not null;default:0"`
ReasoningTokens int64 `gorm:"column:reasoning_tokens;not null;default:0"`
CachedTokens int64 `gorm:"column:cached_tokens;not null;default:0"`
CacheReadTokens int64 `gorm:"column:cache_read_tokens;not null;default:0"`
// CacheReadTokensPresent distinguishes a canonical zero from a legacy CPA
// payload that did not know the cache_read_tokens field.
CacheReadTokensPresent bool `gorm:"column:cache_read_tokens_present;not null;default:false"`
CacheCreationTokens int64 `gorm:"column:cache_creation_tokens;not null;default:0"`
TotalTokens int64 `gorm:"column:total_tokens;not null;default:0"`
TokenAccountingVersion int `gorm:"column:token_accounting_version;not null;default:0;index:idx_usage_token_accounting_version"`
TokenAccountingQuality string `gorm:"column:token_accounting_quality;not null;default:'unclassified'"`
AccountingTotalTokens int64 `gorm:"column:accounting_total_tokens;not null;default:0"`
AccountingInputTokens int64 `gorm:"column:accounting_input_tokens;not null;default:0"`
UncachedInputTokens int64 `gorm:"column:uncached_input_tokens;not null;default:0"`
AccountingCacheReadTokens int64 `gorm:"column:accounting_cache_read_tokens;not null;default:0"`
AccountingCacheWriteTokens int64 `gorm:"column:accounting_cache_write_tokens;not null;default:0"`
AccountingOutputTokens int64 `gorm:"column:accounting_output_tokens;not null;default:0"`
NonReasoningOutputTokens int64 `gorm:"column:non_reasoning_output_tokens;not null;default:0"`
AccountingReasoningTokens int64 `gorm:"column:accounting_reasoning_tokens;not null;default:0"`
UnclassifiedTokens int64 `gorm:"column:unclassified_tokens;not null;default:0"`
Failed bool `` /* 151-byte string literal not displayed */
FailStatusCode int `gorm:"column:fail_status_code;not null;default:0;index:idx_usage_failed_status_time,priority:2"`
FailBody string `gorm:"column:fail_body;type:text"`
Provider string `` /* 152-byte string literal not displayed */
ExecutorType string `gorm:"column:executor_type"`
Model string `gorm:"column:model;index:idx_usage_provider_model,priority:2;index:idx_usage_provider_model_time,priority:2"`
Alias string `gorm:"column:alias"`
Effort string `gorm:"column:effort"`
ServiceTier string `gorm:"column:service_tier"`
ResponseServiceTier string `gorm:"column:response_service_tier"`
Endpoint string `gorm:"column:endpoint;index:idx_usage_endpoint;index:idx_usage_endpoint_time,priority:1"`
AuthType string `gorm:"column:auth_type;index:idx_usage_auth_type_time,priority:1"`
APIKey string `gorm:"column:api_key;index:idx_usage_api_key"`
RequestID string `gorm:"column:request_id;index:idx_usage_request_id"`
UpstreamRequestID string `gorm:"column:upstream_request_id;index:idx_usage_upstream_request_id"`
EventType string `gorm:"column:event_type;index:idx_usage_event_type;index:idx_usage_event_time,priority:1"`
UpstreamStatusCode int `gorm:"column:upstream_status_code;not null;default:0;index:idx_usage_upstream_status_code"`
HomeIP string `gorm:"column:home_ip;index:idx_usage_home_ip;index:idx_usage_home_time,priority:1;index:idx_usage_home_port_time,priority:1"`
HomePort int `gorm:"column:home_port;not null;default:0;index:idx_usage_home_port_time,priority:2"`
CPANodeID string `gorm:"column:cpa_node_id;index:idx_usage_cpa_node_id;index:idx_usage_cpa_node_time,priority:1"`
CPAIP string `gorm:"column:cpa_ip;index:idx_usage_cpa_ip"`
CPAPort int `gorm:"column:cpa_port;not null;default:0"`
CPALabel string `gorm:"column:cpa_label;index:idx_usage_cpa_label"`
TokensJSON JSONB `gorm:"column:tokens"`
FailJSON JSONB `gorm:"column:fail"`
PayloadJSON JSONB `gorm:"column:payload;not null"`
CreatedAt time.Time `gorm:"column:created_at;not null"`
}
func UsageRecordFromPayload ¶
func UsageRecordFromPayload(payload string, homeIP string) (*UsageRecord, error)
UsageRecordFromPayload derives usage record from payload.
func UsageRecordFromPayloadWithRuntime ¶ added in v1.0.63
func UsageRecordFromPayloadWithRuntime(payload string, metadata UsageRuntimeMetadata) (*UsageRecord, error)
UsageRecordFromPayloadWithRuntime derives usage record from payload and trusted runtime metadata.
func (UsageRecord) TableName ¶
func (UsageRecord) TableName() string
TableName returns the database table name.
type UsageRuntimeMetadata ¶ added in v1.0.63
type UsageTokenAccountingBackfillResult ¶ added in v1.0.63
type UsageTokenBreakdown ¶ added in v1.0.63
type UsageTokenBreakdown struct {
SchemaVersion int `json:"schema_version"`
Quality string `json:"quality"`
TotalTokens int64 `json:"total_tokens"`
Input UsageTokenInputBreakdown `json:"input"`
Output UsageTokenOutputBreakdown `json:"output"`
UnclassifiedTokens int64 `json:"unclassified_tokens"`
}
func (UsageTokenBreakdown) Valid ¶ added in v1.0.63
func (b UsageTokenBreakdown) Valid() bool
type UsageTokenInputBreakdown ¶ added in v1.0.63
type UsageTokenOutputBreakdown ¶ added in v1.0.63
type UserMailJobRecord ¶ added in v1.0.63
type UserMailJobRecord struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement;index:idx_user_mail_job_status_next,priority:3"`
UserID uint `gorm:"column:user_id;not null;index:idx_user_mail_job_user_purpose,priority:1"`
Purpose string `gorm:"column:purpose;type:varchar(32);not null;index:idx_user_mail_job_user_purpose,priority:2"`
EmailVersion uint64 `gorm:"column:email_version;not null;default:0"`
SessionVersion uint64 `gorm:"column:session_version;not null;default:0"`
Status string `gorm:"column:status;type:varchar(24);not null;index:idx_user_mail_job_status_next,priority:1"`
Attempts int `gorm:"column:attempts;not null;default:0"`
NextAttemptAt time.Time `gorm:"column:next_attempt_at;not null;index:idx_user_mail_job_status_next,priority:2"`
ClaimedBy string `gorm:"column:claimed_by;type:varchar(128)"`
ClaimExpiresAt *time.Time `gorm:"column:claim_expires_at;index"`
LastErrorCode string `gorm:"column:last_error_code;type:varchar(64)"`
SentAt *time.Time `gorm:"column:sent_at"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (UserMailJobRecord) TableName ¶ added in v1.0.63
func (UserMailJobRecord) TableName() string
TableName returns the database table name.
type UserPeriodLimitResetResult ¶ added in v1.0.63
type UserPeriodLimitResetResult struct {
UserID uint `json:"user_id"`
Mode string `json:"mode"`
Windows []string `json:"windows"`
At time.Time `json:"at"`
Limits UserPeriodLimitsStatus `json:"limits"`
}
UserPeriodLimitResetResult is returned by ResetUserPeriodLimits.
type UserPeriodLimitsStatus ¶ added in v1.0.63
type UserPeriodLimitsStatus struct {
UserID uint `json:"user_id"`
Timezone string `json:"timezone"`
Credits float64 `json:"credits"`
CreditsUnlimited bool `json:"credits_unlimited"`
Windows []UserPeriodWindowStatus `json:"windows"`
}
UserPeriodLimitsStatus is the management-facing aggregate status.
type UserPeriodWindowStatus ¶ added in v1.0.63
type UserPeriodWindowStatus struct {
ID string `json:"id"`
Enabled bool `json:"enabled"`
Limit *float64 `json:"limit"`
Used float64 `json:"used"`
Remaining *float64 `json:"remaining"`
Mode string `json:"mode"`
Active bool `json:"active"`
WindowStart *time.Time `json:"window_start"`
WindowEnd *time.Time `json:"window_end"`
ResetAt *time.Time `json:"reset_at"`
UsageEpoch *time.Time `json:"usage_epoch"`
WeekResetDay *int `json:"week_reset_day,omitempty"`
WeekResetHour *int `json:"week_reset_hour,omitempty"`
}
UserPeriodWindowStatus is the management-facing status for one window.
type UserRecord ¶ added in v1.0.44
type UserRecord struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement;index:idx_user_active_order,priority:2"`
Username string `gorm:"column:username;not null;index;index:idx_user_username_active,priority:1"`
Password string `gorm:"column:password;type:text"`
Email *string `gorm:"column:email;type:text;index"`
EmailVerifiedAt *time.Time `gorm:"column:email_verified_at"`
EmailVersion uint64 `gorm:"column:email_version;not null;default:0"`
SessionVersion uint64 `gorm:"column:session_version;not null;default:0"`
Credits float64 `gorm:"column:credits;not null;default:0"`
CreditsUnlimited bool `gorm:"column:credits_unlimited;not null;default:false"`
Timezone string `gorm:"column:timezone;not null;default:Asia/Shanghai"`
// Period cost limits (null = disabled). Subject is user; all API keys inherit.
// window_mode_*: first_use (default; first billable charge opens a duration
// window, Claude/Codex-style session), sliding (rolling last-N duration),
// calendar (natural day/week/month; 1d/7d/30d only). Legacy alias: fixed -> first_use.
Limit5hCredits *float64 `gorm:"column:limit_5h_credits"`
WindowMode5h string `gorm:"column:window_mode_5h;not null;default:first_use"`
Limit1dCredits *float64 `gorm:"column:limit_1d_credits"`
WindowMode1d string `gorm:"column:window_mode_1d;not null;default:first_use"`
Limit7dCredits *float64 `gorm:"column:limit_7d_credits"`
WindowMode7d string `gorm:"column:window_mode_7d;not null;default:first_use"`
WeekResetDay int `gorm:"column:week_reset_day;not null;default:1"`
WeekResetHour int `gorm:"column:week_reset_hour;not null;default:0"`
Limit30dCredits *float64 `gorm:"column:limit_30d_credits"`
WindowMode30d string `gorm:"column:window_mode_30d;not null;default:first_use"`
// first_use window runtime state (first billable charge opens the window).
PeriodWindowStart5h *time.Time `gorm:"column:period_window_start_5h"`
PeriodWindowStart1d *time.Time `gorm:"column:period_window_start_1d"`
PeriodWindowStart7d *time.Time `gorm:"column:period_window_start_7d"`
PeriodWindowStart30d *time.Time `gorm:"column:period_window_start_30d"`
// Soft reset markers: SUM only counts charges at/after max(window_lower, epoch).
UsageEpoch5h *time.Time `gorm:"column:usage_epoch_5h"`
UsageEpoch1d *time.Time `gorm:"column:usage_epoch_1d"`
UsageEpoch7d *time.Time `gorm:"column:usage_epoch_7d"`
UsageEpoch30d *time.Time `gorm:"column:usage_epoch_30d"`
MFA JSONB `gorm:"column:mfa"`
Passkey JSONB `gorm:"column:passkey"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;index:idx_user_active_order,priority:1;index:idx_user_username_active,priority:2"`
}
func (UserRecord) TableName ¶ added in v1.0.44
func (UserRecord) TableName() string
TableName returns the database table name.
type UserSecurityThrottleRecord ¶ added in v1.0.63
type UserSecurityThrottleRecord struct {
Key string `gorm:"column:key;type:varchar(160);primaryKey"`
Count int `gorm:"column:count;not null;default:0"`
ExpiresAt time.Time `gorm:"column:expires_at;not null;index"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (UserSecurityThrottleRecord) TableName ¶ added in v1.0.63
func (UserSecurityThrottleRecord) TableName() string
TableName returns the database table name.
type UserSecurityTokenRecord ¶ added in v1.0.63
type UserSecurityTokenRecord struct {
ID uint `gorm:"column:id;primaryKey;autoIncrement"`
UserID uint `gorm:"column:user_id;not null;index:idx_user_security_token_user_purpose,priority:1"`
Purpose string `gorm:"column:purpose;type:varchar(32);not null;index:idx_user_security_token_user_purpose,priority:2"`
TokenHash string `gorm:"column:token_hash;type:varchar(64);not null;uniqueIndex"`
EmailVersion uint64 `gorm:"column:email_version;not null;default:0"`
ExpiresAt time.Time `gorm:"column:expires_at;not null;index"`
UsedAt *time.Time `gorm:"column:used_at;index"`
CreatedAt time.Time `gorm:"column:created_at"`
}
func (UserSecurityTokenRecord) TableName ¶ added in v1.0.63
func (UserSecurityTokenRecord) TableName() string
TableName returns the database table name.
type UserUpdate ¶ added in v1.0.44
type UserUpdate struct {
Username *string
Password *string
Email *string
Credits *float64
CreditsUnlimited *bool
MFA *JSONB
Passkey *JSONB
Timezone *string
Limit5hCredits OptionalFloatUpdate
WindowMode5h *string
Limit1dCredits OptionalFloatUpdate
WindowMode1d *string
Limit7dCredits OptionalFloatUpdate
WindowMode7d *string
WeekResetDay *int
WeekResetHour *int
Limit30dCredits OptionalFloatUpdate
WindowMode30d *string
}
type ValidatedDatabaseSnapshot ¶ added in v1.0.63
type ValidatedDatabaseSnapshot struct {
// contains filtered or unexported fields
}
ValidatedDatabaseSnapshot owns an open, structurally validated snapshot archive. Keeping the file open prevents a path replacement race between validation and import on Windows.
func OpenDatabaseSnapshot ¶ added in v1.0.63
func OpenDatabaseSnapshot(ctx context.Context, path string) (*ValidatedDatabaseSnapshot, error)
OpenDatabaseSnapshot validates the archive and individual records before any target database connection is required. Cross-record constraints are checked later inside the target import transaction.
func (*ValidatedDatabaseSnapshot) Close ¶ added in v1.0.63
func (s *ValidatedDatabaseSnapshot) Close() error
Close releases the snapshot archive.
func (*ValidatedDatabaseSnapshot) Manifest ¶ added in v1.0.63
func (s *ValidatedDatabaseSnapshot) Manifest() DatabaseSnapshotManifest
Manifest returns a detached copy of the validated snapshot manifest.
func (*ValidatedDatabaseSnapshot) ValidateForBackend ¶ added in v1.0.63
func (s *ValidatedDatabaseSnapshot) ValidateForBackend(ctx context.Context, backend DatabaseBackend) error
ValidateForBackend runs target-specific checks before the database is opened.
Source Files
¶
- api_keys.go
- app_log.go
- auth_filename.go
- billing.go
- billing_import.go
- certificate.go
- channel_groups.go
- concurrency_admission.go
- concurrency_exchange.go
- concurrency_management.go
- concurrency_models.go
- concurrency_policy.go
- concurrency_release.go
- config.go
- config_snapshot.go
- coordinator.go
- credential_export.go
- credential_reconciliation.go
- database_models.go
- database_snapshot.go
- database_time.go
- db.go
- events.go
- gorm_logger.go
- home_incarnation.go
- import_export.go
- in_flight_cleanup.go
- in_flight_cursor.go
- in_flight_ingest.go
- in_flight_models.go
- in_flight_read.go
- in_flight_types.go
- kv_store.go
- lifecycle_config.go
- membership.go
- model_groups.go
- models.go
- oauth_sessions.go
- plugin_status.go
- plugin_store_auth.go
- plugin_tasks.go
- proxy_pool.go
- quiescence.go
- quota_ingestion.go
- quota_snapshots.go
- refresh.go
- repository.go
- resp.go
- runtime.go
- token_accounting.go
- token_accounting_backfill.go
- usage.go
- usage_observability.go
- user_period_limit.go
- user_security.go
- users.go
- uuid.go