configmanager

package
v2.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigManagerAuthMiddleware

func ConfigManagerAuthMiddleware(next http.Handler) http.Handler

func GetMigrations

func GetMigrations(ctx context.Context, provider string) (*embed.FS, error)

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

func ValidateAndMergeConfig(current *models.Config, key string, value any) (*models.Config, error)

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 (*ConfigManagerPlugin) Close

func (p *ConfigManagerPlugin) Close() error

func (*ConfigManagerPlugin) Config

func (p *ConfigManagerPlugin) Config() any

func (*ConfigManagerPlugin) Init

func (*ConfigManagerPlugin) Metadata

func (*ConfigManagerPlugin) Migrations

func (p *ConfigManagerPlugin) Migrations(ctx context.Context, dbProvider string) (*embed.FS, error)

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.

func (*DatabaseConfigManager) Watch

func (cm *DatabaseConfigManager) Watch(ctx context.Context) (<-chan *models.Config, error)

Watch watches for configuration changes in the database. It uses polling with a 5-second interval to check for configuration version updates.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL