config

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveConfigToDB

func SaveConfigToDB(db *bbolt.DB, cfg *Config) error

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

func LoadConfigFromDB

func LoadConfigFromDB(db *bbolt.DB) (*Config, error)

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) GetConfig

func (cm *ConfigManager) GetConfig() *Config

GetConfig 获取当前配置

func (*ConfigManager) LoadVirtualShadows

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

func (*ConfigManager) Reload

func (cm *ConfigManager) Reload() error

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

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

Jump to

Keyboard shortcuts

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