Documentation
¶
Index ¶
- Constants
- func BackupDB(dbPath, backupDir string) (*model.BackupInfo, error)
- func ClassifyBucket(name string) (category string, clearable bool)
- func ExportDBAsTarGz(dbPath, entryName, archiveType string) ([]byte, string, error)
- func FetchRemoteConfigArchive(host string, port int, token string, useHTTPS bool) ([]byte, string, error)
- func IsConfigBucket(name string) bool
- func RestoreDB(backupPath, targetPath string) error
- type ArchiveManifest
- type BucketStats
- type ConfigExport
- type ConfigImportResult
- type ConfigStore
- func (cs *ConfigStore) DeleteDevice(deviceID string) error
- func (cs *ConfigStore) ExportAllConfig() (*ConfigExport, error)
- func (cs *ConfigStore) HasConfigData() (bool, error)
- func (cs *ConfigStore) HasUsers() (bool, error)
- func (cs *ConfigStore) ImportConfig(export *ConfigExport) error
- func (cs *ConfigStore) ImportConfigReplace(export *ConfigExport, opts ImportPreserveOptions) error
- func (cs *ConfigStore) IsSystemInitialized() (bool, error)
- func (cs *ConfigStore) LoadAICopilotSettings() (*model.AICopilotSettings, error)
- func (cs *ConfigStore) LoadAllDevices() (map[string]model.Device, error)
- func (cs *ConfigStore) LoadChannels() ([]model.Channel, error)
- func (cs *ConfigStore) LoadDevice(deviceID string) (*model.Device, error)
- func (cs *ConfigStore) LoadEdgeRules() ([]model.EdgeRule, error)
- func (cs *ConfigStore) LoadNorthbound() (*model.NorthboundConfig, error)
- func (cs *ConfigStore) LoadServerConfig() (*model.ServerConfig, error)
- func (cs *ConfigStore) LoadSystem() (*model.SystemConfig, error)
- func (cs *ConfigStore) LoadUsers() ([]model.UserConfig, error)
- func (cs *ConfigStore) LoadVirtualShadows() ([]model.VirtualShadowDeviceConfig, error)
- func (cs *ConfigStore) SaveAICopilotSettings(settings model.AICopilotSettings) error
- func (cs *ConfigStore) SaveAllConfig(server model.ServerConfig, channels []model.Channel, devices []model.Device, ...) error
- func (cs *ConfigStore) SaveChannels(channels []model.Channel) error
- func (cs *ConfigStore) SaveDevice(device model.Device) error
- func (cs *ConfigStore) SaveEdgeRules(rules []model.EdgeRule) error
- func (cs *ConfigStore) SaveNorthbound(config model.NorthboundConfig) error
- func (cs *ConfigStore) SaveServerConfig(config model.ServerConfig) error
- func (cs *ConfigStore) SaveSystem(config model.SystemConfig) error
- func (cs *ConfigStore) SaveUsers(users []model.UserConfig) error
- func (cs *ConfigStore) SaveVirtualShadows(devices []model.VirtualShadowDeviceConfig) error
- type ImportArchiveOptions
- type ImportPreserveOptions
- type OfflineMessage
- type Storage
- func (s *Storage) BackupConfigDB(backupDir string) (*model.BackupInfo, error)
- func (s *Storage) BackupRuntimeDB(backupDir string) (*model.BackupInfo, error)
- func (s *Storage) ClearAllRuntimeBuckets() ([]string, error)
- func (s *Storage) ClearBucket(bucketName string) error
- func (s *Storage) Close() error
- func (s *Storage) CompactRuntimeDB() error
- func (s *Storage) DeleteData(bucketName string, key string) error
- func (s *Storage) ExportConfigDBArchive() ([]byte, string, error)
- func (s *Storage) ExportRuntimeDBArchive() ([]byte, string, error)
- func (s *Storage) GetAllValues() (map[string]model.Value, error)
- func (s *Storage) GetBucketStats() ([]BucketStats, int64, error)
- func (s *Storage) GetConfigDB() *bbolt.DB
- func (s *Storage) GetConfigPath() string
- func (s *Storage) GetDB() *bbolt.DB
- func (s *Storage) GetData(bucketName string, key string, result interface{}) error
- func (s *Storage) GetLastValue(pointID string) (*model.Value, error)
- func (s *Storage) GetOfflineMessages(configID string, limit int) ([]OfflineMessage, error)
- func (s *Storage) GetPath() string
- func (s *Storage) GetRuntimePath() string
- func (s *Storage) ImportConfigDBArchive(archiveData []byte, opts ImportArchiveOptions) (*ConfigImportResult, error)
- func (s *Storage) LoadAll(bucketName string, callback func(k, v []byte) error) error
- func (s *Storage) LoadLatest(bucketName string, limit int, callback func(k, v []byte) error) error
- func (s *Storage) LoadRange(bucketName string, minKey, maxKey string, callback func(k, v []byte) error) error
- func (s *Storage) PruneOldest(bucketName string, maxRecords int) error
- func (s *Storage) PullRemoteConfigAndImport(host string, port int, token string, useHTTPS bool) (*ConfigImportResult, error)
- func (s *Storage) RemoveOfflineMessage(key string) error
- func (s *Storage) SaveData(bucketName string, key string, data interface{}) error
- func (s *Storage) SaveOfflineMessage(configID string, data []byte, maxCount int) error
- func (s *Storage) SaveValue(val model.Value) error
- func (s *Storage) SyncConfigDB() error
Constants ¶
const ( BucketValues = "values" BucketRuleState = "RuleState" BucketDataCache = "DataCache" BucketWindow = "WindowData" BucketNorthboundCache = "NorthboundCache" )
const ( BucketConfigVersion = "ConfigVersion" BucketChannels = "Channels" BucketDevices = "Devices" BucketNorthbound = "Northbound" BucketEdgeRules = "EdgeRules" BucketSystem = "System" BucketUsers = "Users" BucketServer = "Server" BucketVirtualShadows = "VirtualShadows" BucketAICopilot = "ai_copilot" ConfigVersionKey = "version" ConfigVersionValue = "1.0" )
const ( ArchiveManifestName = "manifest.json" ConfigDBEntryName = "config.db" RuntimeDBEntryName = "runtime.db" )
Variables ¶
This section is empty.
Functions ¶
func BackupDB ¶
func BackupDB(dbPath, backupDir string) (*model.BackupInfo, error)
BackupDB 将指定数据库文件备份到目标目录,返回备份信息。 用于配置库 / 运行库的备份能力。
func ClassifyBucket ¶ added in v0.0.7
func ExportDBAsTarGz ¶ added in v0.0.7
ExportDBAsTarGz exports a bbolt database file as a tar.gz archive. Used when the database file is not already open (e.g. tests).
func FetchRemoteConfigArchive ¶ added in v0.0.7
func FetchRemoteConfigArchive(host string, port int, token string, useHTTPS bool) ([]byte, string, error)
FetchRemoteConfigArchive downloads a config tar.gz from a remote EdgeX gateway.
func IsConfigBucket ¶
Types ¶
type ArchiveManifest ¶ added in v0.0.7
type ArchiveManifest struct {
Type string `json:"type"`
Version string `json:"version"`
ExportTime time.Time `json:"export_time"`
SourcePath string `json:"source_path,omitempty"`
}
ArchiveManifest describes export package metadata.
type BucketStats ¶
type ConfigExport ¶
type ConfigExport struct {
Server model.ServerConfig `json:"server"`
Channels []model.Channel `json:"channels"`
Devices map[string]model.Device `json:"devices"`
Northbound model.NorthboundConfig `json:"northbound"`
EdgeRules []model.EdgeRule `json:"edge_rules"`
System model.SystemConfig `json:"system"`
Users []model.UserConfig `json:"users"`
VirtualShadows []model.VirtualShadowDeviceConfig `json:"virtual_shadows"`
}
type ConfigImportResult ¶ added in v0.0.7
type ConfigImportResult struct {
ForceOverwrite bool `json:"force_overwrite"`
PreservedUsers bool `json:"preserved_users"`
PreservedPort int `json:"preserved_port"`
DeviceCount int `json:"device_count"`
ChannelCount int `json:"channel_count"`
RemoteSource string `json:"remote_source,omitempty"`
}
ConfigImportResult summarizes a config database import operation.
type ConfigStore ¶
type ConfigStore struct {
// contains filtered or unexported fields
}
func NewConfigStore ¶
func NewConfigStore(db *bbolt.DB) (*ConfigStore, error)
func (*ConfigStore) DeleteDevice ¶
func (cs *ConfigStore) DeleteDevice(deviceID string) error
func (*ConfigStore) ExportAllConfig ¶
func (cs *ConfigStore) ExportAllConfig() (*ConfigExport, error)
func (*ConfigStore) HasConfigData ¶
func (cs *ConfigStore) HasConfigData() (bool, error)
func (*ConfigStore) HasUsers ¶
func (cs *ConfigStore) HasUsers() (bool, error)
func (*ConfigStore) ImportConfig ¶
func (cs *ConfigStore) ImportConfig(export *ConfigExport) error
func (*ConfigStore) ImportConfigReplace ¶ added in v0.0.7
func (cs *ConfigStore) ImportConfigReplace(export *ConfigExport, opts ImportPreserveOptions) error
ImportConfigReplace replaces configuration buckets from export data. When preserve options are set, current users and/or server port are kept.
func (*ConfigStore) IsSystemInitialized ¶
func (cs *ConfigStore) IsSystemInitialized() (bool, error)
func (*ConfigStore) LoadAICopilotSettings ¶ added in v0.0.8
func (cs *ConfigStore) LoadAICopilotSettings() (*model.AICopilotSettings, error)
func (*ConfigStore) LoadAllDevices ¶
func (cs *ConfigStore) LoadAllDevices() (map[string]model.Device, error)
func (*ConfigStore) LoadChannels ¶
func (cs *ConfigStore) LoadChannels() ([]model.Channel, error)
func (*ConfigStore) LoadDevice ¶
func (cs *ConfigStore) LoadDevice(deviceID string) (*model.Device, error)
func (*ConfigStore) LoadEdgeRules ¶
func (cs *ConfigStore) LoadEdgeRules() ([]model.EdgeRule, error)
func (*ConfigStore) LoadNorthbound ¶
func (cs *ConfigStore) LoadNorthbound() (*model.NorthboundConfig, error)
func (*ConfigStore) LoadServerConfig ¶
func (cs *ConfigStore) LoadServerConfig() (*model.ServerConfig, error)
func (*ConfigStore) LoadSystem ¶
func (cs *ConfigStore) LoadSystem() (*model.SystemConfig, error)
func (*ConfigStore) LoadUsers ¶
func (cs *ConfigStore) LoadUsers() ([]model.UserConfig, error)
func (*ConfigStore) LoadVirtualShadows ¶
func (cs *ConfigStore) LoadVirtualShadows() ([]model.VirtualShadowDeviceConfig, error)
func (*ConfigStore) SaveAICopilotSettings ¶ added in v0.0.8
func (cs *ConfigStore) SaveAICopilotSettings(settings model.AICopilotSettings) error
func (*ConfigStore) SaveAllConfig ¶
func (cs *ConfigStore) SaveAllConfig(server model.ServerConfig, channels []model.Channel, devices []model.Device, northbound model.NorthboundConfig, edgeRules []model.EdgeRule, system model.SystemConfig, users []model.UserConfig) error
func (*ConfigStore) SaveChannels ¶
func (cs *ConfigStore) SaveChannels(channels []model.Channel) error
func (*ConfigStore) SaveDevice ¶
func (cs *ConfigStore) SaveDevice(device model.Device) error
func (*ConfigStore) SaveEdgeRules ¶
func (cs *ConfigStore) SaveEdgeRules(rules []model.EdgeRule) error
func (*ConfigStore) SaveNorthbound ¶
func (cs *ConfigStore) SaveNorthbound(config model.NorthboundConfig) error
func (*ConfigStore) SaveServerConfig ¶
func (cs *ConfigStore) SaveServerConfig(config model.ServerConfig) error
func (*ConfigStore) SaveSystem ¶
func (cs *ConfigStore) SaveSystem(config model.SystemConfig) error
func (*ConfigStore) SaveUsers ¶
func (cs *ConfigStore) SaveUsers(users []model.UserConfig) error
func (*ConfigStore) SaveVirtualShadows ¶
func (cs *ConfigStore) SaveVirtualShadows(devices []model.VirtualShadowDeviceConfig) error
type ImportArchiveOptions ¶ added in v0.0.7
type ImportArchiveOptions struct {
ForceOverwrite bool
}
ImportArchiveOptions controls import behavior.
type ImportPreserveOptions ¶ added in v0.0.7
ImportPreserveOptions controls fields preserved during full config import.
type OfflineMessage ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func NewStorage ¶
func (*Storage) BackupConfigDB ¶
func (s *Storage) BackupConfigDB(backupDir string) (*model.BackupInfo, error)
BackupConfigDB 备份配置数据库到指定目录。 配置库优先备份,不包含运行时数据。
func (*Storage) BackupRuntimeDB ¶
func (s *Storage) BackupRuntimeDB(backupDir string) (*model.BackupInfo, error)
BackupRuntimeDB 备份运行时数据库到指定目录(可选诊断用途)。
func (*Storage) ClearAllRuntimeBuckets ¶
ClearAllRuntimeBuckets 清空 runtime.db 中的全部 bucket(含 values、缓存、历史、遗留 WAL 等)。 配置 bucket 不应出现在 runtime.db;若检测到则报错。
func (*Storage) ClearBucket ¶
func (*Storage) CompactRuntimeDB ¶
CompactRuntimeDB 压缩运行时数据库文件,回收已删除数据的空间。 使用 bbolt.Compact 仅复制仍存活的数据,替换原文件。
func (*Storage) ExportConfigDBArchive ¶ added in v0.0.7
ExportConfigDBArchive exports config.db as tar.gz.
func (*Storage) ExportRuntimeDBArchive ¶ added in v0.0.7
ExportRuntimeDBArchive exports runtime.db as tar.gz.
func (*Storage) GetBucketStats ¶
func (s *Storage) GetBucketStats() ([]BucketStats, int64, error)
func (*Storage) GetConfigDB ¶
func (*Storage) GetConfigPath ¶
func (*Storage) GetOfflineMessages ¶
func (s *Storage) GetOfflineMessages(configID string, limit int) ([]OfflineMessage, error)
func (*Storage) GetRuntimePath ¶ added in v0.0.7
GetRuntimePath returns the on-disk path of runtime.db.
func (*Storage) ImportConfigDBArchive ¶ added in v0.0.7
func (s *Storage) ImportConfigDBArchive(archiveData []byte, opts ImportArchiveOptions) (*ConfigImportResult, error)
ImportConfigDBArchive imports configuration from a tar.gz archive. By default existing user accounts/passwords and server port are preserved.
func (*Storage) LoadLatest ¶
func (*Storage) PruneOldest ¶
func (*Storage) PullRemoteConfigAndImport ¶ added in v0.0.7
func (s *Storage) PullRemoteConfigAndImport(host string, port int, token string, useHTTPS bool) (*ConfigImportResult, error)
PullRemoteConfigAndImport force-pulls configuration from a remote gateway and overwrites local config.
func (*Storage) RemoveOfflineMessage ¶
func (*Storage) SaveOfflineMessage ¶
func (*Storage) SyncConfigDB ¶
SyncConfigDB 对配置数据库执行强制同步,确保持久化到磁盘。 配置库使用强一致写入策略。