Documentation
¶
Index ¶
- func ConfigManagerAuthMiddleware(next http.Handler) http.Handler
- func GetMigrations(ctx context.Context, provider string) (*embed.FS, error)
- func NewConfigManager(config *models.Config, db bun.IDB, tokenService services.TokenService) models.ConfigManager
- func NewDatabaseConfigManager(initialConfig *models.Config, db bun.IDB, tokenService services.TokenService) models.ConfigManager
- func ValidateAndMergeConfig(current *models.Config, key string, value any) (*models.Config, error)
- type ConfigEncryptor
- type ConfigManagerPlugin
- func (p *ConfigManagerPlugin) Close() error
- func (p *ConfigManagerPlugin) Config() any
- func (p *ConfigManagerPlugin) Init(ctx *models.PluginContext) error
- func (p *ConfigManagerPlugin) Metadata() models.PluginMetadata
- func (p *ConfigManagerPlugin) Migrations(ctx context.Context, dbProvider string) (*embed.FS, error)
- func (p *ConfigManagerPlugin) Routes() []models.Route
- type DatabaseConfigManager
- func (cm *DatabaseConfigManager) GetConfig() *models.Config
- func (cm *DatabaseConfigManager) Init() error
- func (cm *DatabaseConfigManager) Load() error
- func (cm *DatabaseConfigManager) SetOnConfigUpdate(callback func(config *models.Config) error)
- func (cm *DatabaseConfigManager) Update(key string, value any) error
- func (cm *DatabaseConfigManager) UpdateWithResult(key string, value any, result **models.Config) error
- func (cm *DatabaseConfigManager) Watch(ctx context.Context) (<-chan *models.Config, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMigrations ¶
GetMigrations returns the migrations for the specified database provider.
func NewConfigManager ¶
func NewConfigManager(config *models.Config, db bun.IDB, tokenService services.TokenService) models.ConfigManager
NewConfigManager creates a config manager based on the runtime mode and settings.
func NewDatabaseConfigManager ¶
func NewDatabaseConfigManager(initialConfig *models.Config, db bun.IDB, tokenService services.TokenService) models.ConfigManager
func ValidateAndMergeConfig ¶
ValidateAndMergeConfig converts a config to a map, merges a key-value pair, validates the result, and returns the updated config struct. Optimized to reduce unnecessary marshal/unmarshal operations.
Types ¶
type ConfigEncryptor ¶
type ConfigEncryptor struct {
// contains filtered or unexported fields
}
ConfigEncryptor handles encryption and decryption of sensitive configuration values
func NewConfigEncryptor ¶
func NewConfigEncryptor(secret string, tokenService services.TokenService) *ConfigEncryptor
NewConfigEncryptor creates a new ConfigEncryptor using the app secret
func (*ConfigEncryptor) DecryptConfig ¶
func (ce *ConfigEncryptor) DecryptConfig(encryptedJSON []byte) (*models.Config, error)
DecryptConfig decrypts sensitive fields in the configuration Takes encrypted config JSON and returns decrypted config
func (*ConfigEncryptor) EncryptConfig ¶
func (ce *ConfigEncryptor) EncryptConfig(config *models.Config) ([]byte, error)
EncryptConfig encrypts sensitive fields in the configuration Returns the config as JSON with encrypted values for storage
func (*ConfigEncryptor) EncryptConfigSelectively ¶
func (ce *ConfigEncryptor) EncryptConfigSelectively(oldConfig *models.Config, newConfig *models.Config) ([]byte, error)
EncryptConfigSelectively encrypts only fields that have changed between old and new config. This is optimized for single-field updates and avoids re-encrypting unchanged sensitive fields. Returns the encrypted new config with unchanged sensitive fields copied from the old encrypted config.
type ConfigManagerPlugin ¶
type ConfigManagerPlugin struct {
// contains filtered or unexported fields
}
func New ¶
func New(config types.ConfigManagerPluginConfig) *ConfigManagerPlugin
func (*ConfigManagerPlugin) Close ¶
func (p *ConfigManagerPlugin) Close() error
func (*ConfigManagerPlugin) Config ¶
func (p *ConfigManagerPlugin) Config() any
func (*ConfigManagerPlugin) Init ¶
func (p *ConfigManagerPlugin) Init(ctx *models.PluginContext) error
func (*ConfigManagerPlugin) Metadata ¶
func (p *ConfigManagerPlugin) Metadata() models.PluginMetadata
func (*ConfigManagerPlugin) Migrations ¶
func (*ConfigManagerPlugin) Routes ¶
func (p *ConfigManagerPlugin) Routes() []models.Route
type DatabaseConfigManager ¶
type DatabaseConfigManager struct {
// contains filtered or unexported fields
}
DatabaseConfigManager implements ConfigManager using a database backend.
func (*DatabaseConfigManager) GetConfig ¶
func (cm *DatabaseConfigManager) GetConfig() *models.Config
GetConfig returns the current active configuration.
func (*DatabaseConfigManager) Init ¶
func (cm *DatabaseConfigManager) Init() error
Init creates the initial config in the database from the current active config, but only if the "runtime_config" key does not already exist.
func (*DatabaseConfigManager) Load ¶
func (cm *DatabaseConfigManager) Load() error
Load loads the configuration from the database and updates the active config. If the configuration doesn't exist in the database yet, it initializes it from the current config. After loading, it notifies any registered config watchers.
func (*DatabaseConfigManager) SetOnConfigUpdate ¶
func (cm *DatabaseConfigManager) SetOnConfigUpdate(callback func(config *models.Config) error)
SetOnConfigUpdate sets a callback function to be called when config is updated. This is used to notify config watchers (plugins that implement PluginWithConfigWatcher).
func (*DatabaseConfigManager) Update ¶
func (cm *DatabaseConfigManager) Update(key string, value any) error
Update updates a specific configuration value by key (dot notation) and persists it. After updating the database, it notifies any registered config watchers.
func (*DatabaseConfigManager) UpdateWithResult ¶
func (cm *DatabaseConfigManager) UpdateWithResult(key string, value any, result **models.Config) error
UpdateWithResult updates config and sets the result pointer to the updated config. This allows callers to avoid redundant GetConfig() calls.