config

package
v0.0.0-...-7eaa7e1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const CancelSet = "__CANCEL__"

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance holds our main config logic

func New

func New() (*Instance, error)

func NewCustom

func NewCustom(localPath string, thread *singlethread.Thread, closeThread bool) (*Instance, error)

NewCustom is intended only to be used from tests or internally to this package

func (*Instance) AllKeys

func (i *Instance) AllKeys() []string

AllKeys returns all of the curent config keys

func (*Instance) Close

func (i *Instance) Close() error

func (*Instance) Closed

func (i *Instance) Closed() bool

func (*Instance) ConfigPath

func (i *Instance) ConfigPath() string

ConfigPath returns the path at which our configuration is stored

func (*Instance) Get

func (i *Instance) Get(key string) interface{}

func (*Instance) GetBool

func (i *Instance) GetBool(key string) bool

GetBool retrieves a boolean value for a given key

func (*Instance) GetInt

func (i *Instance) GetInt(key string) int

GetInt retrieves an int for a given key

func (*Instance) GetString

func (i *Instance) GetString(key string) string

GetString retrieves a string for a given key

func (*Instance) GetStringMap

func (i *Instance) GetStringMap(key string) map[string]interface{}

GetStringMap retrieves a map of strings to values for a given key

func (*Instance) GetStringMapStringSlice

func (i *Instance) GetStringMapStringSlice(key string) map[string][]string

GetStringMapStringSlice retrieves a map of string slices for a given key

func (*Instance) GetStringSlice

func (i *Instance) GetStringSlice(key string) []string

GetStringSlice retrieves a slice of strings for a given key

func (*Instance) GetThenSet

func (i *Instance) GetThenSet(key string, valueF func(currentValue interface{}) (interface{}, error)) error

GetThenSet updates a value at the given key. The valueF argument returns the new value to set based on the previous one. If the function returns with an error, the update is cancelled. The function ensures that no-other process or thread can modify the key between reading of the old value and setting the new value.

func (*Instance) GetTime

func (i *Instance) GetTime(key string) time.Time

GetTime retrieves a time instance for a given key

func (*Instance) IsSet

func (i *Instance) IsSet(key string) bool

func (*Instance) Set

func (i *Instance) Set(key string, value interface{}) error

Set sets a value at the given key.

Jump to

Keyboard shortcuts

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