Documentation
¶
Overview ¶
Package config provides live configuration reloading and unification functions.
Index ¶
Constants ¶
const FileDebounce = 10 * time.Millisecond
FileDebounce is the default duration we wait for the contents to have stabilised to work around some editors writing an empty file and then the buffer.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
Validate performs a validation of the provided configuration value, returning a list of invalid paths and a CUE errors.Error explaining the issues found if the configuration is invalid according to the provided schema.
func Vet ¶
Vet performs a validation of the provided configuration, returning a list of invalid paths and a CUE errors.Error explaining the issues found if the configuration is invalid. Vet uses Validate with the config.ModuleDependency schema to globally validate module dependencies and then for each service using either the modules custom scheme held in the Module.Schema field, or if that is empty, the config.DeviceDependency schema.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a configurations stream manager. It holds a progressive configuration state constructed from applying a sequence of configuration changes.
func (*Manager) Apply ¶
Apply applies the provided change to the current configuration state. Any error returned will be fs.PathError.
func (*Manager) Fragments ¶
Fragments returns the currently held configuration fragments. It is intended only for debugging.
func (*Manager) Unify ¶
func (m *Manager) Unify(schema string) (cfg *System, val cue.Value, included, remain []string, err error)
Unify returns a complete unified configuration validated against the provided CUE schema. The configuration is returned as both a *Config and a cue.Value to allow inspection of incomplete unification. The names of files that are included and those that remain to be included is also returned.
type System ¶
Alias the publicly visible types.
func Repair ¶
Repair removes modules and services in cfg that correspond to invalid field paths identified by Vet until no invalid fields are found, and returning the result. Paths referring to invalid fields in the kernel configuration will result in an error. The final result may have no configured module or service.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher collects raw fsnotify.Events and aggregates and filters for semantically meaningful configuration changes.
func NewWatcher ¶
func NewWatcher(ctx context.Context, dir string, changes chan<- Change, debounce time.Duration, log *slog.Logger) (*Watcher, error)
NewWatcher starts an fsnotify.Watcher for the provided directory, sending change events on the changes channel. If dir is deleted, it is recreated as a new directory and a new watcher is set. The debounce parameter specifies how long to wait after an fsnotify.Event before reading the file to ensure that writes will be reflected in the state checksum. If it is less than zero, FileDebounce is used.