config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: GPL-2.0, GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveConfigToDB

func SaveConfigToDB(db storage.KVDB, cfg *Config) error

Types

type Config

type Config struct {
	Server struct {
		Port     int
		LogLevel string
	}
	Storage struct {
		Path string
	}
	Northbound model.NorthboundConfig
	Channels   []model.Channel
	EdgeRules  []model.EdgeRule
	System     model.SystemConfig
	Users      []model.UserConfig
}

func DefaultConfig

func DefaultConfig() *Config

func LoadConfigFromDB

func LoadConfigFromDB(db storage.KVDB) (*Config, error)

type ConfigManager

type ConfigManager struct {
	Config *Config
	// contains filtered or unexported fields
}

ConfigManager 管理配置的加载与持久化(运行时以数据库为唯一数据源)。

func NewConfigManagerWithDB

func NewConfigManagerWithDB(db storage.KVDB) (*ConfigManager, error)

NewConfigManagerWithDB 创建一个使用数据库存储配置的配置管理器

func NewConfigManagerWithEmptyConfig

func NewConfigManagerWithEmptyConfig() *ConfigManager

NewConfigManagerWithEmptyConfig 创建一个使用默认空配置的配置管理器(用于安装前)

func (*ConfigManager) AttachDB

func (cm *ConfigManager) AttachDB(db storage.KVDB)

AttachDB 将运行时数据库绑定到配置管理器(安装完成后使用)

func (*ConfigManager) GetConfig

func (cm *ConfigManager) GetConfig() *Config

GetConfig 获取当前配置

func (*ConfigManager) LoadVirtualShadows

func (cm *ConfigManager) LoadVirtualShadows() ([]model.VirtualShadowDeviceConfig, error)

func (*ConfigManager) OnReload added in v0.1.3

func (cm *ConfigManager) OnReload(fn func(*Config))

OnReload 注册 Reload() 完成后的回调(导入/恢复场景下组件重新挂载新配置)。

func (*ConfigManager) Reload

func (cm *ConfigManager) Reload() error

Reload 从数据库重新加载配置。

func (*ConfigManager) SaveConfig

func (cm *ConfigManager) SaveConfig(cfg *Config) error

SaveConfig 保存配置。 迁移到数据库后,数据库为唯一数据源:useDB 时仅写入数据库, 配置体系以数据库为唯一数据源(legacy YAML 配置已于 2026-10 移除), 不再写回任何文件系统配置目录,避免重建配置目录或写入失败。

func (*ConfigManager) SaveVirtualShadows

func (cm *ConfigManager) SaveVirtualShadows(devices []model.VirtualShadowDeviceConfig) error

Jump to

Keyboard shortcuts

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