config

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfigManager

func NewConfigManager(config *models.Config) models.ConfigManager

NewConfigManager creates a config manager based on the runtime mode and settings. - Library mode: no config manager needed (embedded in API) - Standalone mode: uses database-backed configuration

func NewDatabaseConfigManager

func NewDatabaseConfigManager(initialConfig *models.Config) 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.

Types

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.

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.

func (*DatabaseConfigManager) Watch

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

Watch watches for configuration changes in the database. For PostgreSQL, it uses LISTEN/NOTIFY for efficient pub/sub. For other databases, it uses polling with a 5-second interval.

Jump to

Keyboard shortcuts

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