Documentation
¶
Overview ¶
Package configstore provides a persistent configuration store for Bifrost.
Index ¶
- Constants
- Variables
- func GenerateBudgetHash(b tables.TableBudget) (string, error)
- func GenerateCustomerHash(c tables.TableCustomer) (string, error)
- func GenerateKeyHash(key schemas.Key) (string, error)
- func GenerateMCPClientHash(m tables.TableMCPClient) (string, error)
- func GeneratePluginHash(p tables.TablePlugin) (string, error)
- func GenerateRateLimitHash(rl tables.TableRateLimit) (string, error)
- func GenerateRoutingRuleHash(r tables.TableRoutingRule) (string, error)
- func GenerateTeamHash(t tables.TableTeam) (string, error)
- func GenerateVirtualKeyHash(vk tables.TableVirtualKey) (string, error)
- type AuthConfig
- type ClientConfig
- type Config
- type ConfigMap
- type ConfigStore
- type ConfigStoreType
- type DistributedLock
- func (l *DistributedLock) Extend(ctx context.Context) error
- func (l *DistributedLock) HolderID() string
- func (l *DistributedLock) IsHeld(ctx context.Context) (bool, error)
- func (l *DistributedLock) Key() string
- func (l *DistributedLock) Lock(ctx context.Context) error
- func (l *DistributedLock) LockWithRetry(ctx context.Context, maxRetries int) error
- func (l *DistributedLock) TryLock(ctx context.Context) (bool, error)
- func (l *DistributedLock) Unlock(ctx context.Context) error
- type DistributedLockManager
- type DistributedLockManagerOption
- type EnvKeyInfo
- type EnvKeyType
- type ErrUnresolvedKeys
- type GovernanceConfig
- type LockStore
- type PostgresConfig
- type ProviderConfig
- type RDBConfigStore
- func (s *RDBConfigStore) AddProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, ...) error
- func (s *RDBConfigStore) CleanupExpiredLockByKey(ctx context.Context, lockKey string) (bool, error)
- func (s *RDBConfigStore) CleanupExpiredLocks(ctx context.Context) (int64, error)
- func (s *RDBConfigStore) ClearRestartRequiredConfig(ctx context.Context) error
- func (s *RDBConfigStore) Close(ctx context.Context) error
- func (s *RDBConfigStore) CreateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error
- func (s *RDBConfigStore) CreateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error
- func (s *RDBConfigStore) CreateMCPClientConfig(ctx context.Context, clientConfig *schemas.MCPClientConfig) error
- func (s *RDBConfigStore) CreateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error
- func (s *RDBConfigStore) CreateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error
- func (s *RDBConfigStore) CreateOauthToken(ctx context.Context, token *tables.TableOauthToken) error
- func (s *RDBConfigStore) CreatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
- func (s *RDBConfigStore) CreateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error
- func (s *RDBConfigStore) CreateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error
- func (s *RDBConfigStore) CreateSession(ctx context.Context, session *tables.SessionsTable) error
- func (s *RDBConfigStore) CreateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error
- func (s *RDBConfigStore) CreateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error
- func (s *RDBConfigStore) CreateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, ...) error
- func (s *RDBConfigStore) CreateVirtualKeyProviderConfig(ctx context.Context, ...) error
- func (s *RDBConfigStore) DB() *gorm.DB
- func (s *RDBConfigStore) DeleteCustomer(ctx context.Context, id string) error
- func (s *RDBConfigStore) DeleteMCPClientConfig(ctx context.Context, id string) error
- func (s *RDBConfigStore) DeleteModelConfig(ctx context.Context, id string) error
- func (s *RDBConfigStore) DeleteModelPrices(ctx context.Context, tx ...*gorm.DB) error
- func (s *RDBConfigStore) DeleteOauthToken(ctx context.Context, id string) error
- func (s *RDBConfigStore) DeletePlugin(ctx context.Context, name string, tx ...*gorm.DB) error
- func (s *RDBConfigStore) DeleteProvider(ctx context.Context, provider schemas.ModelProvider, tx ...*gorm.DB) error
- func (s *RDBConfigStore) DeleteRoutingRule(ctx context.Context, id string, tx ...*gorm.DB) error
- func (s *RDBConfigStore) DeleteSession(ctx context.Context, token string) error
- func (s *RDBConfigStore) DeleteTeam(ctx context.Context, id string) error
- func (s *RDBConfigStore) DeleteVirtualKey(ctx context.Context, id string) error
- func (s *RDBConfigStore) DeleteVirtualKeyMCPConfig(ctx context.Context, id uint, tx ...*gorm.DB) error
- func (s *RDBConfigStore) DeleteVirtualKeyProviderConfig(ctx context.Context, id uint, tx ...*gorm.DB) error
- func (s *RDBConfigStore) ExecuteTransaction(ctx context.Context, fn func(tx *gorm.DB) error) error
- func (s *RDBConfigStore) FlushSessions(ctx context.Context) error
- func (s *RDBConfigStore) GetAllRedactedKeys(ctx context.Context, ids []string) ([]schemas.Key, error)
- func (s *RDBConfigStore) GetAuthConfig(ctx context.Context) (*AuthConfig, error)
- func (s *RDBConfigStore) GetBudget(ctx context.Context, id string, tx ...*gorm.DB) (*tables.TableBudget, error)
- func (s *RDBConfigStore) GetBudgets(ctx context.Context) ([]tables.TableBudget, error)
- func (s *RDBConfigStore) GetClientConfig(ctx context.Context) (*ClientConfig, error)
- func (s *RDBConfigStore) GetConfig(ctx context.Context, key string) (*tables.TableGovernanceConfig, error)
- func (s *RDBConfigStore) GetCustomer(ctx context.Context, id string) (*tables.TableCustomer, error)
- func (s *RDBConfigStore) GetCustomers(ctx context.Context) ([]tables.TableCustomer, error)
- func (s *RDBConfigStore) GetExpiringOauthTokens(ctx context.Context, before time.Time) ([]*tables.TableOauthToken, error)
- func (s *RDBConfigStore) GetFrameworkConfig(ctx context.Context) (*tables.TableFrameworkConfig, error)
- func (s *RDBConfigStore) GetGovernanceConfig(ctx context.Context) (*GovernanceConfig, error)
- func (s *RDBConfigStore) GetKeysByIDs(ctx context.Context, ids []string) ([]tables.TableKey, error)
- func (s *RDBConfigStore) GetKeysByProvider(ctx context.Context, provider string) ([]tables.TableKey, error)
- func (s *RDBConfigStore) GetLock(ctx context.Context, lockKey string) (*tables.TableDistributedLock, error)
- func (s *RDBConfigStore) GetLogsStoreConfig(ctx context.Context) (*logstore.Config, error)
- func (s *RDBConfigStore) GetMCPClientByID(ctx context.Context, id string) (*tables.TableMCPClient, error)
- func (s *RDBConfigStore) GetMCPClientByName(ctx context.Context, name string) (*tables.TableMCPClient, error)
- func (s *RDBConfigStore) GetMCPConfig(ctx context.Context) (*schemas.MCPConfig, error)
- func (s *RDBConfigStore) GetModelConfig(ctx context.Context, modelName string, provider *string) (*tables.TableModelConfig, error)
- func (s *RDBConfigStore) GetModelConfigByID(ctx context.Context, id string) (*tables.TableModelConfig, error)
- func (s *RDBConfigStore) GetModelConfigs(ctx context.Context) ([]tables.TableModelConfig, error)
- func (s *RDBConfigStore) GetModelPrices(ctx context.Context) ([]tables.TableModelPricing, error)
- func (s *RDBConfigStore) GetOauthConfigByID(ctx context.Context, id string) (*tables.TableOauthConfig, error)
- func (s *RDBConfigStore) GetOauthConfigByState(ctx context.Context, state string) (*tables.TableOauthConfig, error)
- func (s *RDBConfigStore) GetOauthConfigByTokenID(ctx context.Context, tokenID string) (*tables.TableOauthConfig, error)
- func (s *RDBConfigStore) GetOauthTokenByID(ctx context.Context, id string) (*tables.TableOauthToken, error)
- func (s *RDBConfigStore) GetPlugin(ctx context.Context, name string) (*tables.TablePlugin, error)
- func (s *RDBConfigStore) GetPlugins(ctx context.Context) ([]*tables.TablePlugin, error)
- func (s *RDBConfigStore) GetProvider(ctx context.Context, provider schemas.ModelProvider) (*tables.TableProvider, error)
- func (s *RDBConfigStore) GetProviderByName(ctx context.Context, name string) (*tables.TableProvider, error)
- func (s *RDBConfigStore) GetProviderConfig(ctx context.Context, provider schemas.ModelProvider) (*ProviderConfig, error)
- func (s *RDBConfigStore) GetProviders(ctx context.Context) ([]tables.TableProvider, error)
- func (s *RDBConfigStore) GetProvidersConfig(ctx context.Context) (map[schemas.ModelProvider]ProviderConfig, error)
- func (s *RDBConfigStore) GetProxyConfig(ctx context.Context) (*tables.GlobalProxyConfig, error)
- func (s *RDBConfigStore) GetRateLimit(ctx context.Context, id string) (*tables.TableRateLimit, error)
- func (s *RDBConfigStore) GetRateLimits(ctx context.Context) ([]tables.TableRateLimit, error)
- func (s *RDBConfigStore) GetRedactedRoutingRules(ctx context.Context, ids []string) ([]tables.TableRoutingRule, error)
- func (s *RDBConfigStore) GetRedactedVirtualKeys(ctx context.Context, ids []string) ([]tables.TableVirtualKey, error)
- func (s *RDBConfigStore) GetRestartRequiredConfig(ctx context.Context) (*tables.RestartRequiredConfig, error)
- func (s *RDBConfigStore) GetRoutingRule(ctx context.Context, id string) (*tables.TableRoutingRule, error)
- func (s *RDBConfigStore) GetRoutingRules(ctx context.Context) ([]tables.TableRoutingRule, error)
- func (s *RDBConfigStore) GetRoutingRulesByScope(ctx context.Context, scope string, scopeID string) ([]tables.TableRoutingRule, error)
- func (s *RDBConfigStore) GetSession(ctx context.Context, token string) (*tables.SessionsTable, error)
- func (s *RDBConfigStore) GetTeam(ctx context.Context, id string) (*tables.TableTeam, error)
- func (s *RDBConfigStore) GetTeams(ctx context.Context, customerID string) ([]tables.TableTeam, error)
- func (s *RDBConfigStore) GetVectorStoreConfig(ctx context.Context) (*vectorstore.Config, error)
- func (s *RDBConfigStore) GetVirtualKey(ctx context.Context, id string) (*tables.TableVirtualKey, error)
- func (s *RDBConfigStore) GetVirtualKeyByValue(ctx context.Context, value string) (*tables.TableVirtualKey, error)
- func (s *RDBConfigStore) GetVirtualKeyMCPConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyMCPConfig, error)
- func (s *RDBConfigStore) GetVirtualKeyProviderConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyProviderConfig, error)
- func (s *RDBConfigStore) GetVirtualKeys(ctx context.Context) ([]tables.TableVirtualKey, error)
- func (s *RDBConfigStore) Ping(ctx context.Context) error
- func (s *RDBConfigStore) ReleaseLock(ctx context.Context, lockKey, holderID string) (bool, error)
- func (s *RDBConfigStore) RetryOnNotFound(ctx context.Context, fn func(ctx context.Context) (any, error), maxRetries int, ...) (any, error)
- func (s *RDBConfigStore) RunMigration(ctx context.Context, migration *migrator.Migration) error
- func (s *RDBConfigStore) SetRestartRequiredConfig(ctx context.Context, config *tables.RestartRequiredConfig) error
- func (s *RDBConfigStore) TryAcquireLock(ctx context.Context, lock *tables.TableDistributedLock) (bool, error)
- func (s *RDBConfigStore) UpdateAuthConfig(ctx context.Context, config *AuthConfig) error
- func (s *RDBConfigStore) UpdateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateBudgetUsage(ctx context.Context, id string, currentUsage float64) error
- func (s *RDBConfigStore) UpdateBudgets(ctx context.Context, budgets []*tables.TableBudget, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateClientConfig(ctx context.Context, config *ClientConfig) error
- func (s *RDBConfigStore) UpdateConfig(ctx context.Context, config *tables.TableGovernanceConfig, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateFrameworkConfig(ctx context.Context, config *tables.TableFrameworkConfig) error
- func (s *RDBConfigStore) UpdateLockExpiry(ctx context.Context, lockKey, holderID string, expiresAt time.Time) error
- func (s *RDBConfigStore) UpdateLogsStoreConfig(ctx context.Context, config *logstore.Config) error
- func (s *RDBConfigStore) UpdateMCPClientConfig(ctx context.Context, id string, clientConfig *tables.TableMCPClient) error
- func (s *RDBConfigStore) UpdateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateModelConfigs(ctx context.Context, modelConfigs []*tables.TableModelConfig, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error
- func (s *RDBConfigStore) UpdateOauthToken(ctx context.Context, token *tables.TableOauthToken) error
- func (s *RDBConfigStore) UpdatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, ...) error
- func (s *RDBConfigStore) UpdateProvidersConfig(ctx context.Context, providers map[schemas.ModelProvider]ProviderConfig, ...) error
- func (s *RDBConfigStore) UpdateProxyConfig(ctx context.Context, config *tables.GlobalProxyConfig) error
- func (s *RDBConfigStore) UpdateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateRateLimitUsage(ctx context.Context, id string, tokenCurrentUsage int64, ...) error
- func (s *RDBConfigStore) UpdateRateLimits(ctx context.Context, rateLimits []*tables.TableRateLimit, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateVectorStoreConfig(ctx context.Context, config *vectorstore.Config) error
- func (s *RDBConfigStore) UpdateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpdateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, ...) error
- func (s *RDBConfigStore) UpdateVirtualKeyProviderConfig(ctx context.Context, ...) error
- func (s *RDBConfigStore) UpsertModelPrices(ctx context.Context, pricing *tables.TableModelPricing, tx ...*gorm.DB) error
- func (s *RDBConfigStore) UpsertPlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
- type SQLiteConfig
- type VirtualKeyHashInput
- type VirtualKeyMCPConfigHashInput
- type VirtualKeyProviderConfigHashInput
Constants ¶
const ( DefaultLockTTL = 30 * time.Second DefaultRetryInterval = 100 * time.Millisecond DefaultMaxRetries = 100 DefaultCleanupInterval = 5 * time.Minute )
Default lock configuration values
Variables ¶
var ( ErrLockNotAcquired = errors.New("failed to acquire lock") ErrLockNotHeld = errors.New("lock not held by this holder") ErrLockExpired = errors.New("lock has expired") ErrEmptyLockKey = errors.New("empty lock key") )
Lock errors
var ErrAlreadyExists = errors.New("already exists")
var ErrNotFound = errors.New("not found")
Functions ¶
func GenerateBudgetHash ¶ added in v1.1.46
func GenerateBudgetHash(b tables.TableBudget) (string, error)
GenerateBudgetHash generates a SHA256 hash for a budget. This is used to detect changes to budgets between config.json and database. Skips: LastReset, CurrentUsage, CreatedAt, UpdatedAt (dynamic fields)
func GenerateCustomerHash ¶ added in v1.1.46
func GenerateCustomerHash(c tables.TableCustomer) (string, error)
GenerateCustomerHash generates a SHA256 hash for a customer. This is used to detect changes to customers between config.json and database. Skips: CreatedAt, UpdatedAt, and relationship objects (dynamic fields)
func GenerateKeyHash ¶ added in v1.1.44
GenerateKeyHash generates a SHA256 hash for an individual key. This is used to detect changes to keys between config.json and database. Skips: ID (dynamic UUID), timestamps
func GenerateMCPClientHash ¶ added in v1.1.46
func GenerateMCPClientHash(m tables.TableMCPClient) (string, error)
GenerateMCPClientHash generates a SHA256 hash for an MCP client. This is used to detect changes to MCP clients between config.json and database. Skips: ID (autoIncrement), CreatedAt, UpdatedAt (dynamic fields)
func GeneratePluginHash ¶ added in v1.1.46
func GeneratePluginHash(p tables.TablePlugin) (string, error)
GeneratePluginHash generates a SHA256 hash for a plugin. This is used to detect changes to plugins between config.json and database. Skips: ID (autoIncrement), CreatedAt, UpdatedAt, IsCustom (dynamic fields)
func GenerateRateLimitHash ¶ added in v1.1.46
func GenerateRateLimitHash(rl tables.TableRateLimit) (string, error)
GenerateRateLimitHash generates a SHA256 hash for a rate limit. This is used to detect changes to rate limits between config.json and database. Skips: CurrentUsage, LastReset, CreatedAt, UpdatedAt (dynamic fields)
func GenerateRoutingRuleHash ¶ added in v1.2.17
func GenerateRoutingRuleHash(r tables.TableRoutingRule) (string, error)
GenerateRoutingRuleHash generates a SHA256 hash for a routing rule. This is used to detect changes to routing rules between config.json and database. Skips: CreatedAt, UpdatedAt (dynamic fields)
func GenerateTeamHash ¶ added in v1.1.46
GenerateTeamHash generates a SHA256 hash for a team. This is used to detect changes to teams between config.json and database. Skips: CreatedAt, UpdatedAt, and relationship objects (dynamic fields)
func GenerateVirtualKeyHash ¶ added in v1.1.45
func GenerateVirtualKeyHash(vk tables.TableVirtualKey) (string, error)
GenerateVirtualKeyHash generates a SHA256 hash for a virtual key. This is used to detect changes to virtual keys between config.json and database. Skips: ID (primary key), CreatedAt, UpdatedAt, and relationship objects (Team, Customer, Budget, RateLimit)
Types ¶
type AuthConfig ¶ added in v1.1.20
type AuthConfig struct {
AdminUserName *schemas.EnvVar `json:"admin_username"`
AdminPassword *schemas.EnvVar `json:"admin_password"`
IsEnabled bool `json:"is_enabled"`
DisableAuthOnInference bool `json:"disable_auth_on_inference"`
}
AuthConfig represents configured auth config for Bifrost dashboard
type ClientConfig ¶
type ClientConfig struct {
DropExcessRequests bool `json:"drop_excess_requests"` // Drop excess requests if the provider queue is full
InitialPoolSize int `json:"initial_pool_size"` // The initial pool size for the bifrost client
PrometheusLabels []string `json:"prometheus_labels"` // The labels to be used for prometheus metrics
EnableLogging bool `json:"enable_logging"` // Enable logging of requests and responses
DisableContentLogging bool `json:"disable_content_logging"` // Disable logging of content
DisableDBPingsInHealth bool `json:"disable_db_pings_in_health"`
LogRetentionDays int `json:"log_retention_days" validate:"min=1"` // Number of days to retain logs (minimum 1 day)
EnableGovernance bool `json:"enable_governance"` // Enable governance on all requests
EnforceGovernanceHeader bool `json:"enforce_governance_header"` // Enforce governance on all requests
AllowDirectKeys bool `json:"allow_direct_keys"` // Allow direct keys to be used for requests
AllowedOrigins []string `json:"allowed_origins,omitempty"` // Additional allowed origins for CORS and WebSocket (localhost is always allowed)
AllowedHeaders []string `json:"allowed_headers,omitempty"` // Additional allowed headers for CORS and WebSocket
MaxRequestBodySizeMB int `json:"max_request_body_size_mb"` // The maximum request body size in MB
EnableLiteLLMFallbacks bool `json:"enable_litellm_fallbacks"` // Enable litellm-specific fallbacks for text completion for Groq
MCPAgentDepth int `json:"mcp_agent_depth"` // The maximum depth for MCP agent mode tool execution
MCPToolExecutionTimeout int `json:"mcp_tool_execution_timeout"` // The timeout for individual tool execution in seconds
MCPCodeModeBindingLevel string `json:"mcp_code_mode_binding_level"` // Code mode binding level: "server" or "tool"
MCPToolSyncInterval int `json:"mcp_tool_sync_interval"` // Global tool sync interval in minutes (default: 10, 0 = disabled)
HeaderFilterConfig *tables.GlobalHeaderFilterConfig `json:"header_filter_config,omitempty"` // Global header filtering configuration for x-bf-eh-* headers
ConfigHash string `json:"-"` // Config hash for reconciliation (not serialized)
}
ClientConfig represents the core configuration for Bifrost HTTP transport and the Bifrost Client. It includes settings for excess request handling, Prometheus metrics, and initial pool size.
func (*ClientConfig) GenerateClientConfigHash ¶ added in v1.1.46
func (c *ClientConfig) GenerateClientConfigHash() (string, error)
GenerateClientConfigHash generates a SHA256 hash of the client configuration. This is used to detect changes between config.json and database config.
type Config ¶
type Config struct {
Enabled bool `json:"enabled"`
Type ConfigStoreType `json:"type"`
Config any `json:"config"`
}
Config represents the configuration for the config store.
func (*Config) UnmarshalJSON ¶
UnmarshalJSON unmarshals the config from JSON.
type ConfigMap ¶
type ConfigMap map[schemas.ModelProvider]ProviderConfig
ConfigMap maps provider names to their configurations.
type ConfigStore ¶
type ConfigStore interface {
// Health check
Ping(ctx context.Context) error
// Client config CRUD
UpdateClientConfig(ctx context.Context, config *ClientConfig) error
GetClientConfig(ctx context.Context) (*ClientConfig, error)
// Framework config CRUD
UpdateFrameworkConfig(ctx context.Context, config *tables.TableFrameworkConfig) error
GetFrameworkConfig(ctx context.Context) (*tables.TableFrameworkConfig, error)
// Provider config CRUD
UpdateProvidersConfig(ctx context.Context, providers map[schemas.ModelProvider]ProviderConfig, tx ...*gorm.DB) error
AddProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, tx ...*gorm.DB) error
UpdateProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, tx ...*gorm.DB) error
DeleteProvider(ctx context.Context, provider schemas.ModelProvider, tx ...*gorm.DB) error
GetProvidersConfig(ctx context.Context) (map[schemas.ModelProvider]ProviderConfig, error)
GetProviderConfig(ctx context.Context, provider schemas.ModelProvider) (*ProviderConfig, error)
GetProviders(ctx context.Context) ([]tables.TableProvider, error)
GetProvider(ctx context.Context, provider schemas.ModelProvider) (*tables.TableProvider, error)
// MCP config CRUD
GetMCPConfig(ctx context.Context) (*schemas.MCPConfig, error)
GetMCPClientByID(ctx context.Context, id string) (*tables.TableMCPClient, error)
GetMCPClientByName(ctx context.Context, name string) (*tables.TableMCPClient, error)
CreateMCPClientConfig(ctx context.Context, clientConfig *schemas.MCPClientConfig) error
UpdateMCPClientConfig(ctx context.Context, id string, clientConfig *tables.TableMCPClient) error
DeleteMCPClientConfig(ctx context.Context, id string) error
// Vector store config CRUD
UpdateVectorStoreConfig(ctx context.Context, config *vectorstore.Config) error
GetVectorStoreConfig(ctx context.Context) (*vectorstore.Config, error)
// Logs store config CRUD
UpdateLogsStoreConfig(ctx context.Context, config *logstore.Config) error
GetLogsStoreConfig(ctx context.Context) (*logstore.Config, error)
// Config CRUD
GetConfig(ctx context.Context, key string) (*tables.TableGovernanceConfig, error)
UpdateConfig(ctx context.Context, config *tables.TableGovernanceConfig, tx ...*gorm.DB) error
// Plugins CRUD
GetPlugins(ctx context.Context) ([]*tables.TablePlugin, error)
GetPlugin(ctx context.Context, name string) (*tables.TablePlugin, error)
CreatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
UpsertPlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
UpdatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
DeletePlugin(ctx context.Context, name string, tx ...*gorm.DB) error
// Governance config CRUD
GetVirtualKeys(ctx context.Context) ([]tables.TableVirtualKey, error)
GetRedactedVirtualKeys(ctx context.Context, ids []string) ([]tables.TableVirtualKey, error) // leave ids empty to get all
GetVirtualKey(ctx context.Context, id string) (*tables.TableVirtualKey, error)
GetVirtualKeyByValue(ctx context.Context, value string) (*tables.TableVirtualKey, error)
CreateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error
UpdateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error
DeleteVirtualKey(ctx context.Context, id string) error
// Virtual key provider config CRUD
GetVirtualKeyProviderConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyProviderConfig, error)
CreateVirtualKeyProviderConfig(ctx context.Context, virtualKeyProviderConfig *tables.TableVirtualKeyProviderConfig, tx ...*gorm.DB) error
UpdateVirtualKeyProviderConfig(ctx context.Context, virtualKeyProviderConfig *tables.TableVirtualKeyProviderConfig, tx ...*gorm.DB) error
DeleteVirtualKeyProviderConfig(ctx context.Context, id uint, tx ...*gorm.DB) error
// Virtual key MCP config CRUD
GetVirtualKeyMCPConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyMCPConfig, error)
CreateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, tx ...*gorm.DB) error
UpdateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, tx ...*gorm.DB) error
DeleteVirtualKeyMCPConfig(ctx context.Context, id uint, tx ...*gorm.DB) error
// Team CRUD
GetTeams(ctx context.Context, customerID string) ([]tables.TableTeam, error)
GetTeam(ctx context.Context, id string) (*tables.TableTeam, error)
CreateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error
UpdateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error
DeleteTeam(ctx context.Context, id string) error
// Customer CRUD
GetCustomers(ctx context.Context) ([]tables.TableCustomer, error)
GetCustomer(ctx context.Context, id string) (*tables.TableCustomer, error)
CreateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error
UpdateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error
DeleteCustomer(ctx context.Context, id string) error
// Rate limit CRUD
GetRateLimits(ctx context.Context) ([]tables.TableRateLimit, error)
GetRateLimit(ctx context.Context, id string) (*tables.TableRateLimit, error)
CreateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error
UpdateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error
UpdateRateLimits(ctx context.Context, rateLimits []*tables.TableRateLimit, tx ...*gorm.DB) error
// Budget CRUD
GetBudgets(ctx context.Context) ([]tables.TableBudget, error)
GetBudget(ctx context.Context, id string, tx ...*gorm.DB) (*tables.TableBudget, error)
CreateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error
UpdateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error
UpdateBudgets(ctx context.Context, budgets []*tables.TableBudget, tx ...*gorm.DB) error
UpdateBudgetUsage(ctx context.Context, id string, currentUsage float64) error
UpdateRateLimitUsage(ctx context.Context, id string, tokenCurrentUsage int64, requestCurrentUsage int64) error
// Routing Rules CRUD
GetRoutingRules(ctx context.Context) ([]tables.TableRoutingRule, error)
GetRoutingRulesByScope(ctx context.Context, scope string, scopeID string) ([]tables.TableRoutingRule, error)
GetRoutingRule(ctx context.Context, id string) (*tables.TableRoutingRule, error)
GetRedactedRoutingRules(ctx context.Context, ids []string) ([]tables.TableRoutingRule, error) // leave ids empty to get all
CreateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error
UpdateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error
DeleteRoutingRule(ctx context.Context, id string, tx ...*gorm.DB) error
// Model config CRUD
GetModelConfigs(ctx context.Context) ([]tables.TableModelConfig, error)
GetModelConfig(ctx context.Context, modelName string, provider *string) (*tables.TableModelConfig, error)
GetModelConfigByID(ctx context.Context, id string) (*tables.TableModelConfig, error)
CreateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error
UpdateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error
UpdateModelConfigs(ctx context.Context, modelConfigs []*tables.TableModelConfig, tx ...*gorm.DB) error
DeleteModelConfig(ctx context.Context, id string) error
// Governance config CRUD
GetGovernanceConfig(ctx context.Context) (*GovernanceConfig, error)
// Auth config CRUD
GetAuthConfig(ctx context.Context) (*AuthConfig, error)
UpdateAuthConfig(ctx context.Context, config *AuthConfig) error
// Proxy config CRUD
GetProxyConfig(ctx context.Context) (*tables.GlobalProxyConfig, error)
UpdateProxyConfig(ctx context.Context, config *tables.GlobalProxyConfig) error
// Restart required config CRUD
GetRestartRequiredConfig(ctx context.Context) (*tables.RestartRequiredConfig, error)
SetRestartRequiredConfig(ctx context.Context, config *tables.RestartRequiredConfig) error
ClearRestartRequiredConfig(ctx context.Context) error
// Session CRUD
GetSession(ctx context.Context, token string) (*tables.SessionsTable, error)
CreateSession(ctx context.Context, session *tables.SessionsTable) error
DeleteSession(ctx context.Context, token string) error
FlushSessions(ctx context.Context) error
// Model pricing CRUD
GetModelPrices(ctx context.Context) ([]tables.TableModelPricing, error)
UpsertModelPrices(ctx context.Context, pricing *tables.TableModelPricing, tx ...*gorm.DB) error
DeleteModelPrices(ctx context.Context, tx ...*gorm.DB) error
// Key management
GetKeysByIDs(ctx context.Context, ids []string) ([]tables.TableKey, error)
GetKeysByProvider(ctx context.Context, provider string) ([]tables.TableKey, error)
GetAllRedactedKeys(ctx context.Context, ids []string) ([]schemas.Key, error) // leave ids empty to get all
// Generic transaction manager
ExecuteTransaction(ctx context.Context, fn func(tx *gorm.DB) error) error
// TryAcquireLock attempts to insert a lock row. Returns true if the lock was acquired.
// If the lock already exists and is not expired, returns false.
TryAcquireLock(ctx context.Context, lock *tables.TableDistributedLock) (bool, error)
// GetLock retrieves a lock by its key. Returns nil if the lock doesn't exist.
GetLock(ctx context.Context, lockKey string) (*tables.TableDistributedLock, error)
// UpdateLockExpiry updates the expiration time for an existing lock.
// Only succeeds if the holder ID matches the current lock holder.
UpdateLockExpiry(ctx context.Context, lockKey, holderID string, expiresAt time.Time) error
// ReleaseLock deletes a lock if the holder ID matches.
// Returns true if the lock was released, false if it wasn't held by the given holder.
ReleaseLock(ctx context.Context, lockKey, holderID string) (bool, error)
// CleanupExpiredLockByKey atomically deletes a specific lock only if it has expired.
// Returns true if an expired lock was deleted, false if the lock doesn't exist or hasn't expired.
CleanupExpiredLockByKey(ctx context.Context, lockKey string) (bool, error)
// CleanupExpiredLocks removes all locks that have expired.
// Returns the number of locks cleaned up.
CleanupExpiredLocks(ctx context.Context) (int64, error)
// OAuth config CRUD
GetOauthConfigByID(ctx context.Context, id string) (*tables.TableOauthConfig, error)
GetOauthConfigByState(ctx context.Context, state string) (*tables.TableOauthConfig, error)
GetOauthConfigByTokenID(ctx context.Context, tokenID string) (*tables.TableOauthConfig, error)
CreateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error
UpdateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error
// OAuth token CRUD
GetOauthTokenByID(ctx context.Context, id string) (*tables.TableOauthToken, error)
GetExpiringOauthTokens(ctx context.Context, before time.Time) ([]*tables.TableOauthToken, error)
CreateOauthToken(ctx context.Context, token *tables.TableOauthToken) error
UpdateOauthToken(ctx context.Context, token *tables.TableOauthToken) error
DeleteOauthToken(ctx context.Context, id string) error
// Not found retry wrapper
RetryOnNotFound(ctx context.Context, fn func(ctx context.Context) (any, error), maxRetries int, retryDelay time.Duration) (any, error)
// DB returns the underlying database connection.
DB() *gorm.DB
// Migration manager
RunMigration(ctx context.Context, migration *migrator.Migration) error
// Cleanup
Close(ctx context.Context) error
}
ConfigStore is the interface for the config store.
func NewConfigStore ¶
func NewConfigStore(ctx context.Context, config *Config, logger schemas.Logger) (ConfigStore, error)
NewConfigStore creates a new config store based on the configuration
type ConfigStoreType ¶
type ConfigStoreType string
ConfigStoreType represents the type of config store.
const ( ConfigStoreTypeSQLite ConfigStoreType = "sqlite" ConfigStoreTypePostgres ConfigStoreType = "postgres" )
ConfigStoreTypeSQLite is the type of config store for SQLite.
type DistributedLock ¶ added in v1.2.9
type DistributedLock struct {
// contains filtered or unexported fields
}
DistributedLock represents a distributed lock that can be acquired and released across multiple processes or instances.
func (*DistributedLock) Extend ¶ added in v1.2.9
func (l *DistributedLock) Extend(ctx context.Context) error
Extend extends the lock's TTL. This is useful for long-running operations that need to hold the lock longer than the initial TTL. Returns an error if the lock is not held by this holder or has expired. Only clears l.acquired when ErrLockNotHeld is returned; transient errors leave l.acquired untouched so Unlock() can still attempt a proper release.
func (*DistributedLock) HolderID ¶ added in v1.2.9
func (l *DistributedLock) HolderID() string
HolderID returns the unique identifier for this lock holder.
func (*DistributedLock) IsHeld ¶ added in v1.2.9
func (l *DistributedLock) IsHeld(ctx context.Context) (bool, error)
IsHeld checks if the lock is currently held by this holder. Note: This checks the local state and the database state. Returns (false, error) on transient database errors without clearing l.acquired, allowing Unlock() to still attempt a proper release.
func (*DistributedLock) Key ¶ added in v1.2.9
func (l *DistributedLock) Key() string
Key returns the lock key.
func (*DistributedLock) Lock ¶ added in v1.2.9
func (l *DistributedLock) Lock(ctx context.Context) error
Lock acquires the lock, blocking until it's available or the context is cancelled. It will make up to (maxRetries + 1) attempts, sleeping retryInterval between failed attempts.
func (*DistributedLock) LockWithRetry ¶ added in v1.2.9
func (l *DistributedLock) LockWithRetry(ctx context.Context, maxRetries int) error
LockWithRetry acquires the lock, blocking until it's available or the context is cancelled. It will retry up to maxRetries times with retryInterval between attempts.
type DistributedLockManager ¶ added in v1.2.9
type DistributedLockManager struct {
// contains filtered or unexported fields
}
DistributedLockManager creates and manages distributed locks. It provides a factory for creating locks with consistent configuration.
func NewDistributedLockManager ¶ added in v1.2.9
func NewDistributedLockManager(store LockStore, logger schemas.Logger, opts ...DistributedLockManagerOption) *DistributedLockManager
NewDistributedLockManager creates a new lock manager with the given store and options.
func (*DistributedLockManager) CleanupExpiredLocks ¶ added in v1.2.9
func (m *DistributedLockManager) CleanupExpiredLocks(ctx context.Context) (int64, error)
CleanupExpiredLocks removes all expired locks from the store. This can be called periodically to clean up stale locks.
func (*DistributedLockManager) NewLock ¶ added in v1.2.9
func (m *DistributedLockManager) NewLock(lockKey string) (*DistributedLock, error)
NewLock creates a new DistributedLock for the given key. The lock is not acquired until Lock() or TryLock() is called. Returns an error if the lock key is empty.
func (*DistributedLockManager) NewLockWithTTL ¶ added in v1.2.9
func (m *DistributedLockManager) NewLockWithTTL(lockKey string, ttl time.Duration) (*DistributedLock, error)
NewLockWithTTL creates a new DistributedLock with a custom TTL. Returns an error if the lock key is empty.
type DistributedLockManagerOption ¶ added in v1.2.9
type DistributedLockManagerOption func(*DistributedLockManager)
DistributedLockManagerOption is a function that configures a DistributedLockManager.
func WithDefaultTTL ¶ added in v1.2.9
func WithDefaultTTL(ttl time.Duration) DistributedLockManagerOption
WithDefaultTTL sets the default TTL for locks created by this manager.
func WithMaxRetries ¶ added in v1.2.9
func WithMaxRetries(maxRetries int) DistributedLockManagerOption
WithMaxRetries sets the maximum number of retries for lock acquisition.
func WithRetryInterval ¶ added in v1.2.9
func WithRetryInterval(interval time.Duration) DistributedLockManagerOption
WithRetryInterval sets the interval between lock acquisition retries.
type EnvKeyInfo ¶
type EnvKeyInfo struct {
EnvVar string // The environment variable name (without env. prefix)
Provider schemas.ModelProvider // The provider this key belongs to (empty for core/mcp configs)
KeyType EnvKeyType // Type of key (e.g., "api_key", "azure_config", "vertex_config", "bedrock_config", "connection_string", "mcp_header")
ConfigPath string // Path in config where this env var is used
KeyID string // The key ID this env var belongs to (empty for non-key configs like bedrock_config, connection_string)
}
EnvKeyInfo stores information about a key sourced from environment
type EnvKeyType ¶
type EnvKeyType string
const ( EnvKeyTypeAPIKey EnvKeyType = "api_key" EnvKeyTypeAzureConfig EnvKeyType = "azure_config" EnvKeyTypeVertexConfig EnvKeyType = "vertex_config" EnvKeyTypeBedrockConfig EnvKeyType = "bedrock_config" EnvKeyTypeConnection EnvKeyType = "connection_string" EnvKeyTypeMCPHeader EnvKeyType = "mcp_header" )
type ErrUnresolvedKeys ¶ added in v1.1.54
type ErrUnresolvedKeys struct {
Identifiers []string
}
ErrUnresolvedKeys is returned when one or more keys could not be resolved
func (*ErrUnresolvedKeys) Error ¶ added in v1.1.54
func (e *ErrUnresolvedKeys) Error() string
type GovernanceConfig ¶
type GovernanceConfig struct {
VirtualKeys []tables.TableVirtualKey `json:"virtual_keys"`
Teams []tables.TableTeam `json:"teams"`
Customers []tables.TableCustomer `json:"customers"`
Budgets []tables.TableBudget `json:"budgets"`
RateLimits []tables.TableRateLimit `json:"rate_limits"`
ModelConfigs []tables.TableModelConfig `json:"model_configs"`
Providers []tables.TableProvider `json:"providers"`
RoutingRules []tables.TableRoutingRule `json:"routing_rules"`
AuthConfig *AuthConfig `json:"auth_config,omitempty"`
}
type LockStore ¶ added in v1.2.9
type LockStore interface {
// TryAcquireLock attempts to insert a lock row. Returns true if the lock was acquired.
// If the lock already exists and is not expired, returns false.
TryAcquireLock(ctx context.Context, lock *tables.TableDistributedLock) (bool, error)
// GetLock retrieves a lock by its key. Returns nil if the lock doesn't exist.
GetLock(ctx context.Context, lockKey string) (*tables.TableDistributedLock, error)
// UpdateLockExpiry updates the expiration time for an existing lock.
// Only succeeds if the holder ID matches the current lock holder.
UpdateLockExpiry(ctx context.Context, lockKey, holderID string, expiresAt time.Time) error
// ReleaseLock deletes a lock if the holder ID matches.
// Returns true if the lock was released, false if it wasn't held by the given holder.
ReleaseLock(ctx context.Context, lockKey, holderID string) (bool, error)
// CleanupExpiredLocks removes all locks that have expired.
// Returns the number of locks cleaned up.
CleanupExpiredLocks(ctx context.Context) (int64, error)
// CleanupExpiredLockByKey atomically deletes a lock only if it has expired.
// Returns true if an expired lock was deleted, false if the lock doesn't exist or hasn't expired.
CleanupExpiredLockByKey(ctx context.Context, lockKey string) (bool, error)
}
LockStore defines the storage operations required for distributed locking. This interface abstracts the database operations, making the lock implementation testable and decoupled from the specific database implementation.
type PostgresConfig ¶ added in v1.1.0
type PostgresConfig struct {
Host *schemas.EnvVar `json:"host"`
Port *schemas.EnvVar `json:"port"`
User *schemas.EnvVar `json:"user"`
Password *schemas.EnvVar `json:"password"`
DBName *schemas.EnvVar `json:"db_name"`
SSLMode *schemas.EnvVar `json:"ssl_mode"`
MaxIdleConns int `json:"max_idle_conns"`
MaxOpenConns int `json:"max_open_conns"`
}
PostgresConfig represents the configuration for a Postgres database.
type ProviderConfig ¶
type ProviderConfig struct {
Keys []schemas.Key `json:"keys"` // API keys for the provider with UUIDs
NetworkConfig *schemas.NetworkConfig `json:"network_config,omitempty"` // Network-related settings
ConcurrencyAndBufferSize *schemas.ConcurrencyAndBufferSize `json:"concurrency_and_buffer_size,omitempty"` // Concurrency settings
ProxyConfig *schemas.ProxyConfig `json:"proxy_config,omitempty"` // Proxy configuration
SendBackRawRequest bool `json:"send_back_raw_request"` // Include raw request in BifrostResponse
SendBackRawResponse bool `json:"send_back_raw_response"` // Include raw response in BifrostResponse
CustomProviderConfig *schemas.CustomProviderConfig `json:"custom_provider_config,omitempty"` // Custom provider configuration
ConfigHash string `json:"config_hash,omitempty"` // Hash of config.json version, used for change detection
}
ProviderConfig represents the configuration for a specific AI model provider. It includes API keys, network settings, and concurrency settings.
func (*ProviderConfig) GenerateConfigHash ¶ added in v1.1.44
func (p *ProviderConfig) GenerateConfigHash(providerName string) (string, error)
GenerateConfigHash generates a SHA256 hash of the provider configuration. This is used to detect changes between config.json and database config. Keys are excluded as they are hashed separately.
func (*ProviderConfig) Redacted ¶ added in v1.2.15
func (p *ProviderConfig) Redacted() *ProviderConfig
Redacted returns a redacted copy of the provider configuration.
type RDBConfigStore ¶ added in v1.1.0
type RDBConfigStore struct {
// contains filtered or unexported fields
}
RDBConfigStore represents a configuration store that uses a relational database.
func (*RDBConfigStore) AddProvider ¶ added in v1.1.0
func (s *RDBConfigStore) AddProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, tx ...*gorm.DB) error
AddProvider creates a new provider configuration in the database.
func (*RDBConfigStore) CleanupExpiredLockByKey ¶ added in v1.2.9
CleanupExpiredLockByKey atomically deletes a specific lock only if it has expired. Returns true if an expired lock was deleted, false if the lock doesn't exist or hasn't expired.
func (*RDBConfigStore) CleanupExpiredLocks ¶ added in v1.2.9
func (s *RDBConfigStore) CleanupExpiredLocks(ctx context.Context) (int64, error)
CleanupExpiredLocks removes all locks that have expired. Returns the number of locks cleaned up.
func (*RDBConfigStore) ClearRestartRequiredConfig ¶ added in v1.1.53
func (s *RDBConfigStore) ClearRestartRequiredConfig(ctx context.Context) error
ClearRestartRequiredConfig clears the restart required configuration in the database.
func (*RDBConfigStore) Close ¶ added in v1.1.0
func (s *RDBConfigStore) Close(ctx context.Context) error
Close closes the SQLite config store.
func (*RDBConfigStore) CreateBudget ¶ added in v1.1.0
func (s *RDBConfigStore) CreateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error
CreateBudget creates a new budget in the database.
func (*RDBConfigStore) CreateCustomer ¶ added in v1.1.0
func (s *RDBConfigStore) CreateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error
CreateCustomer creates a new customer in the database.
func (*RDBConfigStore) CreateMCPClientConfig ¶ added in v1.1.10
func (s *RDBConfigStore) CreateMCPClientConfig(ctx context.Context, clientConfig *schemas.MCPClientConfig) error
CreateMCPClientConfig creates a new MCP client configuration in the database.
func (*RDBConfigStore) CreateModelConfig ¶ added in v1.2.13
func (s *RDBConfigStore) CreateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error
CreateModelConfig creates a new model config in the database.
func (*RDBConfigStore) CreateOauthConfig ¶ added in v1.2.17
func (s *RDBConfigStore) CreateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error
CreateOauthConfig creates a new OAuth config
func (*RDBConfigStore) CreateOauthToken ¶ added in v1.2.17
func (s *RDBConfigStore) CreateOauthToken(ctx context.Context, token *tables.TableOauthToken) error
CreateOauthToken creates a new OAuth token
func (*RDBConfigStore) CreatePlugin ¶ added in v1.1.0
func (s *RDBConfigStore) CreatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
CreatePlugin creates a new plugin in the database.
func (*RDBConfigStore) CreateRateLimit ¶ added in v1.1.0
func (s *RDBConfigStore) CreateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error
CreateRateLimit creates a new rate limit in the database.
func (*RDBConfigStore) CreateRoutingRule ¶ added in v1.2.17
func (s *RDBConfigStore) CreateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error
CreateRoutingRule creates a new routing rule in the database.
func (*RDBConfigStore) CreateSession ¶ added in v1.1.20
func (s *RDBConfigStore) CreateSession(ctx context.Context, session *tables.SessionsTable) error
CreateSession creates a new session in the database.
func (*RDBConfigStore) CreateTeam ¶ added in v1.1.0
func (s *RDBConfigStore) CreateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error
CreateTeam creates a new team in the database.
func (*RDBConfigStore) CreateVirtualKey ¶ added in v1.1.0
func (s *RDBConfigStore) CreateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error
func (*RDBConfigStore) CreateVirtualKeyMCPConfig ¶ added in v1.1.10
func (s *RDBConfigStore) CreateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, tx ...*gorm.DB) error
CreateVirtualKeyMCPConfig creates a new virtual key MCP config in the database.
func (*RDBConfigStore) CreateVirtualKeyProviderConfig ¶ added in v1.1.0
func (s *RDBConfigStore) CreateVirtualKeyProviderConfig(ctx context.Context, virtualKeyProviderConfig *tables.TableVirtualKeyProviderConfig, tx ...*gorm.DB) error
CreateVirtualKeyProviderConfig creates a new virtual key provider config in the database.
func (*RDBConfigStore) DB ¶ added in v1.1.5
func (s *RDBConfigStore) DB() *gorm.DB
DB returns the underlying database connection.
func (*RDBConfigStore) DeleteCustomer ¶ added in v1.1.0
func (s *RDBConfigStore) DeleteCustomer(ctx context.Context, id string) error
DeleteCustomer deletes a customer from the database.
func (*RDBConfigStore) DeleteMCPClientConfig ¶ added in v1.1.10
func (s *RDBConfigStore) DeleteMCPClientConfig(ctx context.Context, id string) error
DeleteMCPClientConfig deletes an MCP client configuration from the database.
func (*RDBConfigStore) DeleteModelConfig ¶ added in v1.2.13
func (s *RDBConfigStore) DeleteModelConfig(ctx context.Context, id string) error
DeleteModelConfig deletes a model config from the database.
func (*RDBConfigStore) DeleteModelPrices ¶ added in v1.1.0
DeleteModelPrices deletes all model pricing records from the database.
func (*RDBConfigStore) DeleteOauthToken ¶ added in v1.2.17
func (s *RDBConfigStore) DeleteOauthToken(ctx context.Context, id string) error
DeleteOauthToken deletes an OAuth token by its ID
func (*RDBConfigStore) DeletePlugin ¶ added in v1.1.0
func (*RDBConfigStore) DeleteProvider ¶ added in v1.1.0
func (s *RDBConfigStore) DeleteProvider(ctx context.Context, provider schemas.ModelProvider, tx ...*gorm.DB) error
DeleteProvider deletes a single provider and all its associated keys from the database.
func (*RDBConfigStore) DeleteRoutingRule ¶ added in v1.2.17
DeleteRoutingRule deletes a routing rule from the database.
func (*RDBConfigStore) DeleteSession ¶ added in v1.1.20
func (s *RDBConfigStore) DeleteSession(ctx context.Context, token string) error
DeleteSession deletes a session from the database.
func (*RDBConfigStore) DeleteTeam ¶ added in v1.1.0
func (s *RDBConfigStore) DeleteTeam(ctx context.Context, id string) error
DeleteTeam deletes a team from the database.
func (*RDBConfigStore) DeleteVirtualKey ¶ added in v1.1.0
func (s *RDBConfigStore) DeleteVirtualKey(ctx context.Context, id string) error
DeleteVirtualKey deletes a virtual key from the database.
func (*RDBConfigStore) DeleteVirtualKeyMCPConfig ¶ added in v1.1.10
func (s *RDBConfigStore) DeleteVirtualKeyMCPConfig(ctx context.Context, id uint, tx ...*gorm.DB) error
DeleteVirtualKeyMCPConfig deletes a virtual key provider config from the database.
func (*RDBConfigStore) DeleteVirtualKeyProviderConfig ¶ added in v1.1.0
func (s *RDBConfigStore) DeleteVirtualKeyProviderConfig(ctx context.Context, id uint, tx ...*gorm.DB) error
DeleteVirtualKeyProviderConfig deletes a virtual key provider config from the database.
func (*RDBConfigStore) ExecuteTransaction ¶ added in v1.1.0
ExecuteTransaction executes a transaction.
func (*RDBConfigStore) FlushSessions ¶ added in v1.1.59
func (s *RDBConfigStore) FlushSessions(ctx context.Context) error
FlushSessions flushes all sessions from the database.
func (*RDBConfigStore) GetAllRedactedKeys ¶ added in v1.1.24
func (s *RDBConfigStore) GetAllRedactedKeys(ctx context.Context, ids []string) ([]schemas.Key, error)
GetAllRedactedKeys retrieves all redacted keys from the database.
func (*RDBConfigStore) GetAuthConfig ¶ added in v1.1.20
func (s *RDBConfigStore) GetAuthConfig(ctx context.Context) (*AuthConfig, error)
GetAuthConfig retrieves the auth configuration from the database.
func (*RDBConfigStore) GetBudget ¶ added in v1.1.0
func (s *RDBConfigStore) GetBudget(ctx context.Context, id string, tx ...*gorm.DB) (*tables.TableBudget, error)
GetBudget retrieves a specific budget from the database.
func (*RDBConfigStore) GetBudgets ¶ added in v1.1.0
func (s *RDBConfigStore) GetBudgets(ctx context.Context) ([]tables.TableBudget, error)
GetBudgets retrieves all budgets from the database.
func (*RDBConfigStore) GetClientConfig ¶ added in v1.1.0
func (s *RDBConfigStore) GetClientConfig(ctx context.Context) (*ClientConfig, error)
GetClientConfig retrieves the client configuration from the database.
func (*RDBConfigStore) GetConfig ¶ added in v1.1.0
func (s *RDBConfigStore) GetConfig(ctx context.Context, key string) (*tables.TableGovernanceConfig, error)
GetConfig retrieves a specific config from the database.
func (*RDBConfigStore) GetCustomer ¶ added in v1.1.0
func (s *RDBConfigStore) GetCustomer(ctx context.Context, id string) (*tables.TableCustomer, error)
GetCustomer retrieves a specific customer from the database.
func (*RDBConfigStore) GetCustomers ¶ added in v1.1.0
func (s *RDBConfigStore) GetCustomers(ctx context.Context) ([]tables.TableCustomer, error)
GetCustomers retrieves all customers from the database.
func (*RDBConfigStore) GetExpiringOauthTokens ¶ added in v1.2.17
func (s *RDBConfigStore) GetExpiringOauthTokens(ctx context.Context, before time.Time) ([]*tables.TableOauthToken, error)
GetExpiringOauthTokens retrieves tokens that are expiring before the given time
func (*RDBConfigStore) GetFrameworkConfig ¶ added in v1.1.8
func (s *RDBConfigStore) GetFrameworkConfig(ctx context.Context) (*tables.TableFrameworkConfig, error)
GetFrameworkConfig retrieves the framework configuration from the database.
func (*RDBConfigStore) GetGovernanceConfig ¶ added in v1.1.0
func (s *RDBConfigStore) GetGovernanceConfig(ctx context.Context) (*GovernanceConfig, error)
GetGovernanceConfig retrieves the governance configuration from the database.
func (*RDBConfigStore) GetKeysByIDs ¶ added in v1.1.0
GetKeysByIDs retrieves multiple keys by their IDs
func (*RDBConfigStore) GetKeysByProvider ¶ added in v1.1.40
func (s *RDBConfigStore) GetKeysByProvider(ctx context.Context, provider string) ([]tables.TableKey, error)
GetKeysByProvider retrieves all keys for a specific provider
func (*RDBConfigStore) GetLock ¶ added in v1.2.9
func (s *RDBConfigStore) GetLock(ctx context.Context, lockKey string) (*tables.TableDistributedLock, error)
GetLock retrieves a lock by its key. Returns nil if the lock doesn't exist.
func (*RDBConfigStore) GetLogsStoreConfig ¶ added in v1.1.0
GetLogsStoreConfig retrieves the logs store configuration from the database.
func (*RDBConfigStore) GetMCPClientByID ¶ added in v1.2.17
func (s *RDBConfigStore) GetMCPClientByID(ctx context.Context, id string) (*tables.TableMCPClient, error)
GetMCPClientByID retrieves an MCP client by ID from the database.
func (*RDBConfigStore) GetMCPClientByName ¶ added in v1.1.10
func (s *RDBConfigStore) GetMCPClientByName(ctx context.Context, name string) (*tables.TableMCPClient, error)
GetMCPClientByName retrieves an MCP client by name from the database.
func (*RDBConfigStore) GetMCPConfig ¶ added in v1.1.0
GetMCPConfig retrieves the MCP configuration from the database.
func (*RDBConfigStore) GetModelConfig ¶ added in v1.2.13
func (s *RDBConfigStore) GetModelConfig(ctx context.Context, modelName string, provider *string) (*tables.TableModelConfig, error)
GetModelConfig retrieves a specific model config from the database by model name and optional provider.
func (*RDBConfigStore) GetModelConfigByID ¶ added in v1.2.13
func (s *RDBConfigStore) GetModelConfigByID(ctx context.Context, id string) (*tables.TableModelConfig, error)
GetModelConfigByID retrieves a specific model config from the database by ID.
func (*RDBConfigStore) GetModelConfigs ¶ added in v1.2.13
func (s *RDBConfigStore) GetModelConfigs(ctx context.Context) ([]tables.TableModelConfig, error)
GetModelConfigs retrieves all model configs from the database.
func (*RDBConfigStore) GetModelPrices ¶ added in v1.1.0
func (s *RDBConfigStore) GetModelPrices(ctx context.Context) ([]tables.TableModelPricing, error)
GetModelPrices retrieves all model pricing records from the database.
func (*RDBConfigStore) GetOauthConfigByID ¶ added in v1.2.17
func (s *RDBConfigStore) GetOauthConfigByID(ctx context.Context, id string) (*tables.TableOauthConfig, error)
GetOauthConfigByID retrieves an OAuth config by its ID
func (*RDBConfigStore) GetOauthConfigByState ¶ added in v1.2.17
func (s *RDBConfigStore) GetOauthConfigByState(ctx context.Context, state string) (*tables.TableOauthConfig, error)
GetOauthConfigByState retrieves an OAuth config by its state token State is unique per OAuth flow (used for CSRF protection on callback)
func (*RDBConfigStore) GetOauthConfigByTokenID ¶ added in v1.2.17
func (s *RDBConfigStore) GetOauthConfigByTokenID(ctx context.Context, tokenID string) (*tables.TableOauthConfig, error)
GetOauthConfigByTokenID retrieves an OAuth config that references a specific token
func (*RDBConfigStore) GetOauthTokenByID ¶ added in v1.2.17
func (s *RDBConfigStore) GetOauthTokenByID(ctx context.Context, id string) (*tables.TableOauthToken, error)
GetOauthTokenByID retrieves an OAuth token by its ID
func (*RDBConfigStore) GetPlugin ¶ added in v1.1.0
func (s *RDBConfigStore) GetPlugin(ctx context.Context, name string) (*tables.TablePlugin, error)
func (*RDBConfigStore) GetPlugins ¶ added in v1.1.0
func (s *RDBConfigStore) GetPlugins(ctx context.Context) ([]*tables.TablePlugin, error)
func (*RDBConfigStore) GetProvider ¶ added in v1.2.15
func (s *RDBConfigStore) GetProvider(ctx context.Context, provider schemas.ModelProvider) (*tables.TableProvider, error)
GetProvider retrieves a provider by name from the database with governance relationships.
func (*RDBConfigStore) GetProviderByName ¶ added in v1.2.13
func (s *RDBConfigStore) GetProviderByName(ctx context.Context, name string) (*tables.TableProvider, error)
GetProviderByName retrieves a provider by name from the database with governance relationships.
func (*RDBConfigStore) GetProviderConfig ¶ added in v1.2.9
func (s *RDBConfigStore) GetProviderConfig(ctx context.Context, provider schemas.ModelProvider) (*ProviderConfig, error)
GetProviderConfig retrieves the provider configuration from the database.
func (*RDBConfigStore) GetProviders ¶ added in v1.2.13
func (s *RDBConfigStore) GetProviders(ctx context.Context) ([]tables.TableProvider, error)
GetProviders retrieves all providers from the database with their governance relationships.
func (*RDBConfigStore) GetProvidersConfig ¶ added in v1.1.0
func (s *RDBConfigStore) GetProvidersConfig(ctx context.Context) (map[schemas.ModelProvider]ProviderConfig, error)
GetProvidersConfig retrieves the provider configuration from the database.
func (*RDBConfigStore) GetProxyConfig ¶ added in v1.1.44
func (s *RDBConfigStore) GetProxyConfig(ctx context.Context) (*tables.GlobalProxyConfig, error)
GetProxyConfig retrieves the proxy configuration from the database.
func (*RDBConfigStore) GetRateLimit ¶ added in v1.1.0
func (s *RDBConfigStore) GetRateLimit(ctx context.Context, id string) (*tables.TableRateLimit, error)
GetRateLimit retrieves a specific rate limit from the database.
func (*RDBConfigStore) GetRateLimits ¶ added in v1.2.0
func (s *RDBConfigStore) GetRateLimits(ctx context.Context) ([]tables.TableRateLimit, error)
GetRateLimits retrieves all rate limits from the database.
func (*RDBConfigStore) GetRedactedRoutingRules ¶ added in v1.2.17
func (s *RDBConfigStore) GetRedactedRoutingRules(ctx context.Context, ids []string) ([]tables.TableRoutingRule, error)
GetRedactedRoutingRules retrieves redacted routing rules from the database.
func (*RDBConfigStore) GetRedactedVirtualKeys ¶ added in v1.1.24
func (s *RDBConfigStore) GetRedactedVirtualKeys(ctx context.Context, ids []string) ([]tables.TableVirtualKey, error)
func (*RDBConfigStore) GetRestartRequiredConfig ¶ added in v1.1.53
func (s *RDBConfigStore) GetRestartRequiredConfig(ctx context.Context) (*tables.RestartRequiredConfig, error)
GetRestartRequiredConfig retrieves the restart required configuration from the database.
func (*RDBConfigStore) GetRoutingRule ¶ added in v1.2.17
func (s *RDBConfigStore) GetRoutingRule(ctx context.Context, id string) (*tables.TableRoutingRule, error)
GetRoutingRule retrieves a specific routing rule by ID.
func (*RDBConfigStore) GetRoutingRules ¶ added in v1.2.17
func (s *RDBConfigStore) GetRoutingRules(ctx context.Context) ([]tables.TableRoutingRule, error)
GetRoutingRules retrieves all routing rules from the database.
func (*RDBConfigStore) GetRoutingRulesByScope ¶ added in v1.2.17
func (s *RDBConfigStore) GetRoutingRulesByScope(ctx context.Context, scope string, scopeID string) ([]tables.TableRoutingRule, error)
GetRoutingRulesByScope retrieves routing rules by scope and scope ID, ordered by priority ASC.
func (*RDBConfigStore) GetSession ¶ added in v1.1.20
func (s *RDBConfigStore) GetSession(ctx context.Context, token string) (*tables.SessionsTable, error)
GetSession retrieves a session from the database.
func (*RDBConfigStore) GetTeam ¶ added in v1.1.0
GetTeam retrieves a specific team from the database.
func (*RDBConfigStore) GetTeams ¶ added in v1.1.0
func (s *RDBConfigStore) GetTeams(ctx context.Context, customerID string) ([]tables.TableTeam, error)
GetTeams retrieves all teams from the database.
func (*RDBConfigStore) GetVectorStoreConfig ¶ added in v1.1.0
func (s *RDBConfigStore) GetVectorStoreConfig(ctx context.Context) (*vectorstore.Config, error)
GetVectorStoreConfig retrieves the vector store configuration from the database.
func (*RDBConfigStore) GetVirtualKey ¶ added in v1.1.0
func (s *RDBConfigStore) GetVirtualKey(ctx context.Context, id string) (*tables.TableVirtualKey, error)
GetVirtualKey retrieves a virtual key from the database.
func (*RDBConfigStore) GetVirtualKeyByValue ¶ added in v1.1.0
func (s *RDBConfigStore) GetVirtualKeyByValue(ctx context.Context, value string) (*tables.TableVirtualKey, error)
GetVirtualKeyByValue retrieves a virtual key by its value
func (*RDBConfigStore) GetVirtualKeyMCPConfigs ¶ added in v1.1.10
func (s *RDBConfigStore) GetVirtualKeyMCPConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyMCPConfig, error)
GetVirtualKeyMCPConfigs retrieves all virtual key MCP configs from the database.
func (*RDBConfigStore) GetVirtualKeyProviderConfigs ¶ added in v1.1.0
func (s *RDBConfigStore) GetVirtualKeyProviderConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyProviderConfig, error)
GetVirtualKeyProviderConfigs retrieves all virtual key provider configs from the database.
func (*RDBConfigStore) GetVirtualKeys ¶ added in v1.1.0
func (s *RDBConfigStore) GetVirtualKeys(ctx context.Context) ([]tables.TableVirtualKey, error)
GetVirtualKeys retrieves all virtual keys from the database.
func (*RDBConfigStore) Ping ¶ added in v1.1.8
func (s *RDBConfigStore) Ping(ctx context.Context) error
Ping checks if the database is reachable.
func (*RDBConfigStore) ReleaseLock ¶ added in v1.2.9
ReleaseLock deletes a lock if the holder ID matches. Returns true if the lock was released, false if it wasn't held by the given holder.
func (*RDBConfigStore) RetryOnNotFound ¶ added in v1.2.0
func (s *RDBConfigStore) RetryOnNotFound(ctx context.Context, fn func(ctx context.Context) (any, error), maxRetries int, retryDelay time.Duration) (any, error)
RetryOnNotFound retries a function up to 3 times with 1-second delays if it returns ErrNotFound
func (*RDBConfigStore) RunMigration ¶ added in v1.1.5
RunMigration runs a migration.
func (*RDBConfigStore) SetRestartRequiredConfig ¶ added in v1.1.53
func (s *RDBConfigStore) SetRestartRequiredConfig(ctx context.Context, config *tables.RestartRequiredConfig) error
SetRestartRequiredConfig sets the restart required configuration in the database.
func (*RDBConfigStore) TryAcquireLock ¶ added in v1.2.9
func (s *RDBConfigStore) TryAcquireLock(ctx context.Context, lock *tables.TableDistributedLock) (bool, error)
TryAcquireLock attempts to insert a lock row. Returns true if the lock was acquired. Uses INSERT ... ON CONFLICT DO NOTHING for atomic lock acquisition.
func (*RDBConfigStore) UpdateAuthConfig ¶ added in v1.1.20
func (s *RDBConfigStore) UpdateAuthConfig(ctx context.Context, config *AuthConfig) error
UpdateAuthConfig updates the auth configuration in the database.
func (*RDBConfigStore) UpdateBudget ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error
UpdateBudget updates a budget in the database.
func (*RDBConfigStore) UpdateBudgetUsage ¶ added in v1.2.13
func (s *RDBConfigStore) UpdateBudgetUsage(ctx context.Context, id string, currentUsage float64) error
UpdateBudgetUsage updates only the current_usage field of a budget. Uses SkipHooks to avoid triggering BeforeSave validation since we're only updating usage.
func (*RDBConfigStore) UpdateBudgets ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateBudgets(ctx context.Context, budgets []*tables.TableBudget, tx ...*gorm.DB) error
UpdateBudgets updates multiple budgets in the database.
func (*RDBConfigStore) UpdateClientConfig ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateClientConfig(ctx context.Context, config *ClientConfig) error
UpdateClientConfig updates the client configuration in the database.
func (*RDBConfigStore) UpdateConfig ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateConfig(ctx context.Context, config *tables.TableGovernanceConfig, tx ...*gorm.DB) error
UpdateConfig updates a specific config in the database.
func (*RDBConfigStore) UpdateCustomer ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error
UpdateCustomer updates an existing customer in the database.
func (*RDBConfigStore) UpdateFrameworkConfig ¶ added in v1.1.8
func (s *RDBConfigStore) UpdateFrameworkConfig(ctx context.Context, config *tables.TableFrameworkConfig) error
UpdateFrameworkConfig updates the framework configuration in the database.
func (*RDBConfigStore) UpdateLockExpiry ¶ added in v1.2.9
func (s *RDBConfigStore) UpdateLockExpiry(ctx context.Context, lockKey, holderID string, expiresAt time.Time) error
UpdateLockExpiry updates the expiration time for an existing lock. Only succeeds if the holder ID matches the current lock holder.
func (*RDBConfigStore) UpdateLogsStoreConfig ¶ added in v1.1.0
UpdateLogsStoreConfig updates the logs store configuration in the database.
func (*RDBConfigStore) UpdateMCPClientConfig ¶ added in v1.1.10
func (s *RDBConfigStore) UpdateMCPClientConfig(ctx context.Context, id string, clientConfig *tables.TableMCPClient) error
UpdateMCPClientConfig updates an existing MCP client configuration in the database.
func (*RDBConfigStore) UpdateModelConfig ¶ added in v1.2.13
func (s *RDBConfigStore) UpdateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error
UpdateModelConfig updates a model config in the database.
func (*RDBConfigStore) UpdateModelConfigs ¶ added in v1.2.13
func (s *RDBConfigStore) UpdateModelConfigs(ctx context.Context, modelConfigs []*tables.TableModelConfig, tx ...*gorm.DB) error
UpdateModelConfigs updates multiple model configs in the database.
func (*RDBConfigStore) UpdateOauthConfig ¶ added in v1.2.17
func (s *RDBConfigStore) UpdateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error
UpdateOauthConfig updates an existing OAuth config
func (*RDBConfigStore) UpdateOauthToken ¶ added in v1.2.17
func (s *RDBConfigStore) UpdateOauthToken(ctx context.Context, token *tables.TableOauthToken) error
UpdateOauthToken updates an existing OAuth token
func (*RDBConfigStore) UpdatePlugin ¶ added in v1.1.0
func (s *RDBConfigStore) UpdatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
UpdatePlugin updates an existing plugin in the database.
func (*RDBConfigStore) UpdateProvider ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, tx ...*gorm.DB) error
UpdateProvider updates a single provider configuration in the database without deleting/recreating.
func (*RDBConfigStore) UpdateProvidersConfig ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateProvidersConfig(ctx context.Context, providers map[schemas.ModelProvider]ProviderConfig, tx ...*gorm.DB) error
UpdateProvidersConfig updates the client configuration in the database.
func (*RDBConfigStore) UpdateProxyConfig ¶ added in v1.1.44
func (s *RDBConfigStore) UpdateProxyConfig(ctx context.Context, config *tables.GlobalProxyConfig) error
UpdateProxyConfig updates the proxy configuration in the database.
func (*RDBConfigStore) UpdateRateLimit ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error
UpdateRateLimit updates a rate limit in the database.
func (*RDBConfigStore) UpdateRateLimitUsage ¶ added in v1.2.13
func (s *RDBConfigStore) UpdateRateLimitUsage(ctx context.Context, id string, tokenCurrentUsage int64, requestCurrentUsage int64) error
UpdateRateLimitUsage updates only the usage fields of a rate limit. Uses SkipHooks to avoid triggering BeforeSave validation since we're only updating usage.
func (*RDBConfigStore) UpdateRateLimits ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateRateLimits(ctx context.Context, rateLimits []*tables.TableRateLimit, tx ...*gorm.DB) error
UpdateRateLimits updates multiple rate limits in the database.
func (*RDBConfigStore) UpdateRoutingRule ¶ added in v1.2.17
func (s *RDBConfigStore) UpdateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error
UpdateRoutingRule updates an existing routing rule in the database. It enforces the same unique-priority-per-scope invariant as CreateRoutingRule.
func (*RDBConfigStore) UpdateTeam ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error
UpdateTeam updates an existing team in the database.
func (*RDBConfigStore) UpdateVectorStoreConfig ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateVectorStoreConfig(ctx context.Context, config *vectorstore.Config) error
UpdateVectorStoreConfig updates the vector store configuration in the database.
func (*RDBConfigStore) UpdateVirtualKey ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error
func (*RDBConfigStore) UpdateVirtualKeyMCPConfig ¶ added in v1.1.10
func (s *RDBConfigStore) UpdateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, tx ...*gorm.DB) error
UpdateVirtualKeyMCPConfig updates a virtual key provider config in the database.
func (*RDBConfigStore) UpdateVirtualKeyProviderConfig ¶ added in v1.1.0
func (s *RDBConfigStore) UpdateVirtualKeyProviderConfig(ctx context.Context, virtualKeyProviderConfig *tables.TableVirtualKeyProviderConfig, tx ...*gorm.DB) error
UpdateVirtualKeyProviderConfig updates a virtual key provider config in the database.
func (*RDBConfigStore) UpsertModelPrices ¶ added in v1.2.9
func (s *RDBConfigStore) UpsertModelPrices(ctx context.Context, pricing *tables.TableModelPricing, tx ...*gorm.DB) error
UpsertModelPrices creates or updates a model pricing record in the database.
func (*RDBConfigStore) UpsertPlugin ¶ added in v1.1.40
func (s *RDBConfigStore) UpsertPlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
UpsertPlugin creates a new plugin in the database if it doesn't exist, otherwise updates it.
type SQLiteConfig ¶
type SQLiteConfig struct {
Path string `json:"path"`
}
SQLiteConfig represents the configuration for a SQLite database.
type VirtualKeyHashInput ¶ added in v1.1.45
type VirtualKeyHashInput struct {
Name string
Description string
IsActive bool
TeamID *string
CustomerID *string
BudgetID *string
RateLimitID *string
// ProviderConfigs and MCPConfigs are hashed separately as they contain nested data
ProviderConfigs []VirtualKeyProviderConfigHashInput
MCPConfigs []VirtualKeyMCPConfigHashInput
}
VirtualKeyHashInput represents the fields used for virtual key hash generation. This struct is used to create a consistent hash from TableVirtualKey, excluding dynamic fields like ID, timestamps, and relationship objects.
type VirtualKeyMCPConfigHashInput ¶ added in v1.1.45
VirtualKeyMCPConfigHashInput represents MCP config fields for hashing
type VirtualKeyProviderConfigHashInput ¶ added in v1.1.45
type VirtualKeyProviderConfigHashInput struct {
Provider string
Weight float64
AllowedModels []string
BudgetID *string
RateLimitID *string
KeyIDs []string // Only key IDs, not full key objects
}
VirtualKeyProviderConfigHashInput represents provider config fields for hashing