configx

package
v4.0.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: AGPL-3.0 Imports: 13 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 GetReference added in v4.0.1

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

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 WithJSON

func WithJSON() Option

func WithLock

func WithLock(m *sync.RWMutex) Option

func WithMarshaller

func WithMarshaller(m Marshaller) 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 {
	*sync.RWMutex
	Unmarshaler
	Marshaller
	Encrypter
	Decrypter

	SetCallback func([]string, interface{}) error

	AutoUpdate bool

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

type Receiver

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

type Ref

type Ref interface {
	Get() string
}

func Reference

func Reference(s string) Ref

type Scanner

type Scanner interface {
	Scan(interface{}) 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
	Interface() interface{}
	Int() int
	Int64() int64
	Duration() time.Duration
	String() string
	StringMap() map[string]string
	StringArray() []string
	Slice() []interface{}
	Map() map[string]interface{}

	Scanner
}

type Values

type Values interface {
	Entrypoint
	Value
}

func New

func New(opts ...Option) Values

func NewFrom

func NewFrom(i interface{}) Values

type WalkFunc added in v4.0.1

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

type Watcher

type Watcher interface {
	Watch(path ...string) (Receiver, error)
}

Jump to

Keyboard shortcuts

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