Back to

Package config

Latest Go to latest

The latest major version is v3.

Published: Dec 8, 2019 | License: Apache-2.0 | Module:


Package config is an interface for dynamic configuration.



var (
	// Default Config Manager
	DefaultConfig = NewConfig()

func Bytes

func Bytes() []byte

Return config as raw json

func Get

func Get(path ...string) reader.Value

Get a value from the config

func Load

func Load(source ...source.Source) error

Load config sources

func LoadFile

func LoadFile(path string) error

LoadFile is short hand for creating a file source and loading it

func Map

func Map() map[string]interface{}

Return config as a map

func Scan

func Scan(v interface{}) error

Scan values to a go type

func Sync

func Sync() error

Force a source changeset sync

type Config

type Config interface {
	// provide the reader.Values interface
	// Stop the config loader/watcher
	Close() error
	// Load config sources
	Load(source ...source.Source) error
	// Force a source changeset sync
	Sync() error
	// Watch a value for changes
	Watch(path ...string) (Watcher, error)

Config is an interface abstraction for dynamic configuration

func NewConfig

func NewConfig(opts ...Option) Config

NewConfig returns new config

type Option

type Option func(o *Options)

func WithLoader

func WithLoader(l loader.Loader) Option

WithLoader sets the loader for manager config

func WithReader

func WithReader(r reader.Reader) Option

WithReader sets the config reader

func WithSource

func WithSource(s source.Source) Option

WithSource appends a source to list of sources

type Options

type Options struct {
	Loader loader.Loader
	Reader reader.Reader
	Source []source.Source

	// for alternative data
	Context context.Context

type Watcher

type Watcher interface {
	Next() (reader.Value, error)
	Stop() error

Watcher is the config watcher

func Watch

func Watch(path ...string) (Watcher, error)

Watch a value for changes

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier