Documentation
¶
Index ¶
- func SaveConfigToDB(db *bbolt.DB, cfg *Config) error
- type Config
- type ConfigManager
- func (cm *ConfigManager) AttachDB(db *bbolt.DB)
- func (cm *ConfigManager) GetConfig() *Config
- func (cm *ConfigManager) LoadVirtualShadows() ([]model.VirtualShadowDeviceConfig, error)
- 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 `yaml:"port"`
LogLevel string `yaml:"logLevel"`
} `yaml:"server"`
Storage struct {
Path string `yaml:"path"`
} `yaml:"storage"`
Northbound model.NorthboundConfig `yaml:"northbound"`
Channels []model.Channel `yaml:"channels"`
EdgeRules []model.EdgeRule `yaml:"edge_rules"`
System model.SystemConfig `yaml:"system"`
Users []model.UserConfig `yaml:"users"`
}
func DefaultConfig ¶
func DefaultConfig() *Config
type ConfigManager ¶
type ConfigManager struct {
Config *Config
ConfDir string
// contains filtered or unexported fields
}
ConfigManager 管理配置的加载与持久化(运行时以数据库为唯一数据源)。
func NewConfigManagerWithDB ¶
func NewConfigManagerWithDB(confDir string, db *bbolt.DB) (*ConfigManager, error)
NewConfigManagerWithDB 创建一个使用数据库存储配置的配置管理器
func NewConfigManagerWithEmptyConfig ¶
func NewConfigManagerWithEmptyConfig(confDir string) *ConfigManager
NewConfigManagerWithEmptyConfig 创建一个使用默认空配置的配置管理器(用于安装前)
func (*ConfigManager) AttachDB ¶
func (cm *ConfigManager) AttachDB(db *bbolt.DB)
AttachDB 将运行时数据库绑定到配置管理器(安装完成后使用)
func (*ConfigManager) LoadVirtualShadows ¶
func (cm *ConfigManager) LoadVirtualShadows() ([]model.VirtualShadowDeviceConfig, error)
func (*ConfigManager) SaveConfig ¶
func (cm *ConfigManager) SaveConfig(cfg *Config) error
SaveConfig 保存配置。 迁移到数据库后,数据库为唯一数据源:useDB 时仅写入数据库, 不再写回已废弃(可能已删除)的 conf/*.yaml,避免重建配置目录或写入失败。
func (*ConfigManager) SaveVirtualShadows ¶
func (cm *ConfigManager) SaveVirtualShadows(devices []model.VirtualShadowDeviceConfig) error
Click to show internal directories.
Click to hide internal directories.