store

package
v16.16.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Location added in v16.12.0

func Location(filepath string) string

Location returns the path to the config file. If no path is provided, different standard location will be probed: - os.UserConfigDir() + /datarhei-core/config.json - os.UserHomeDir() + /.config/datarhei-core/config.json - ./config/config.json If the config doesn't exist in none of these locations, it will be assumed at ./config/config.json

Types

type DataVersion

type DataVersion struct {
	Version int64 `json:"version"`
}

type Store

type Store interface {
	// Get the current configuration.
	Get() *config.Config

	// Set a new configuration for persistence.
	Set(data *config.Config) error

	// GetActive returns the configuration that has been set as
	// active before, otherwise it return nil.
	GetActive() *config.Config

	// SetActive will keep the given configuration
	// as active in memory. It can be retrieved later with GetActive()
	SetActive(data *config.Config) error

	// Reload will reload the stored configuration. It has to make sure
	// that all affected components will receiver their potentially
	// changed configuration.
	Reload() error
}

Store is a store for the configuration data.

func NewJSON

func NewJSON(f fs.Filesystem, path string, reloadFn func()) (Store, error)

NewJSONStore will read the JSON config file from the given path. After successfully reading it in, it will be written back to the path. The returned error will be nil if everything went fine. If the path doesn't exist, a default JSON config file will be written to that path. The returned ConfigStore can be used to retrieve or write the config.

Jump to

Keyboard shortcuts

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