Documentation
¶
Index ¶
- func SaveConfigToDB(db storage.KVDB, cfg *Config) error
- type Config
- type ConfigManager
- func (cm *ConfigManager) AttachDB(db storage.KVDB)
- func (cm *ConfigManager) GetConfig() *Config
- func (cm *ConfigManager) LoadVirtualShadows() ([]model.VirtualShadowDeviceConfig, error)
- func (cm *ConfigManager) OnReload(fn func(*Config))
- func (cm *ConfigManager) Reload() error
- func (cm *ConfigManager) SaveConfig(cfg *Config) error
- func (cm *ConfigManager) SaveVirtualShadows(devices []model.VirtualShadowDeviceConfig) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
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) 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) 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
Click to show internal directories.
Click to hide internal directories.