configx

package
v4.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: AGPL-3.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMarshallerDefined  = errors.New("no marshaller defined")
	ErrNoUnmarshalerDefined = errors.New("no unmarshaler defined")
)

Functions

func FormatPath

func FormatPath(ii ...interface{}) string

func StringToKeys

func StringToKeys(s ...string) []string

func Walk added in v4.0.1

func Walk(v Values, fn WalkFunc) error

Types

type Decrypter

type Decrypter interface {
	Decrypt(string) ([]byte, error)
}

type Encrypter

type Encrypter interface {
	Encrypt([]byte) (string, error)
}

type Entrypoint

type Entrypoint interface {
	KVStore
	Val(path ...string) Values
}

type KV

type KV struct {
	Key   string
	Value interface{}
}

TODO - we should be returning a Value

type KVStore

type KVStore interface {
	Get() Value
	Set(value interface{}) error
	Del() error
}

type Key

type Key interface{}

type Marshaller

type Marshaller interface {
	Marshal(interface{}) ([]byte, error)
}

type Option

type Option func(*Options)

func WithDecrypt

func WithDecrypt(d Decrypter) Option

func WithEncrypt

func WithEncrypt(e Encrypter) Option

func WithInitData added in v4.0.6

func WithInitData(data interface{}) Option

func WithJSON

func WithJSON() Option

func WithMarshaller

func WithMarshaller(m Marshaller) Option

func WithReadOnly added in v4.0.1

func WithReadOnly() Option

func WithSetCallback added in v4.0.1

func WithSetCallback(f func([]string, interface{}) error) Option

func WithString added in v4.0.1

func WithString() Option

func WithUnmarshaler

func WithUnmarshaler(u Unmarshaler) Option

func WithYAML

func WithYAML() Option

type Options

type Options struct {
	InitData interface{}
	Unmarshaler
	Marshaller
	Encrypter
	Decrypter

	// Additional callback after Set is called
	SetCallback func([]string, interface{}) error

	// Do not create any resources
	ReadOnly bool

	// Used to pass other potential options
	Context context.Context
}

type Receiver

type Receiver interface {
	Next() (interface{}, error)
	Stop()
}

type Ref

type Ref interface {
	Get() string
}

func GetReference added in v4.0.1

func GetReference(i interface{}) (Ref, bool)

func Reference

func Reference(s string) Ref

type Scanner

type Scanner interface {
	Scan(interface{}, ...Option) error
}

type Source

type Source interface {
	Entrypoint
	Watcher
}

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte, interface{}) error
}

type Value

type Value interface {
	Default(interface{}) Value

	Bool() bool
	Bytes() []byte
	Key() []string
	Reference() Ref
	Interface() interface{}
	Int() int
	Int64() int64
	Duration() time.Duration
	String() string
	StringMap() map[string]string
	StringArray() []string
	Slice() []interface{}
	Map() map[string]interface{}

	Clone() Value

	Scanner
}

type Values

type Values interface {
	Entrypoint
	Value
}

func New

func New(opts ...Option) Values

type WalkFunc added in v4.0.1

type WalkFunc func(key []string, v Value) error

type WatchOption added in v4.0.1

type WatchOption func(*WatchOptions)

func WithChangesOnly added in v4.0.1

func WithChangesOnly() WatchOption

func WithPath added in v4.0.1

func WithPath(path ...string) WatchOption

type WatchOptions added in v4.0.1

type WatchOptions struct {
	Path        []string
	ChangesOnly bool
}

type Watcher

type Watcher interface {
	Watch(opts ...WatchOption) (Receiver, error)
}

Jump to

Keyboard shortcuts

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