config

package
v0.0.0-...-99d84d4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory func() any

Factory creates a struct to pass to an Unmarshaller then an Updater

type Manager

type Manager interface {
	// EtcDir returns the path to the etc directory
	EtcDir() string
	// ReadJson will read a yaml file from inside etc
	ReadJson(n string, o any) error
	// ReadJsonOptional is the same as ReadJson except that the file not existing will not
	// return an error
	ReadJsonOptional(n string, o any) error
	// ReadYaml will read a yaml file from inside etc
	ReadYaml(n string, o any) error
	// ReadYamlOptional is the same as ReadYaml except that the file not existing will not
	// return an error
	ReadYamlOptional(n string, o any) error
	// FixPath ensures that, if the path is relative it will point to EtcDir().
	// This will do nothing is s==nil or *s==""
	FixPath(s *string)
	// ReadAndWatch read with a custom Unmarshaller but also if the file ever changes.
	ReadAndWatch(n string, f Factory, u Updater, um Unmarshaller) error
	// WatchDirectory watches a directory and passes all changes to a single Updater
	WatchDirectory(d string, f Factory, u Updater, um Unmarshaller)
}

type Unmarshaller

type Unmarshaller func([]byte, interface{}) error

Unmarshaller will be called to unmarshal a file when it changes. Usually this is yaml.Unmarshal but it can be a custom format

type Updater

type Updater func(fsnotify.Event, any) error

Updater is a function that will be notified of changes

Jump to

Keyboard shortcuts

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