go-micro: github.com/micro/go-micro/config Index | Files | Directories

package config

import "github.com/micro/go-micro/config"

Package config is an interface for dynamic configuration.

Index

Package Files

config.go default.go options.go value.go

Variables

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

func Bytes Uses

func Bytes() []byte

Return config as raw json

func Get Uses

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

Get a value from the config

func Load Uses

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

Load config sources

func LoadFile Uses

func LoadFile(path string) error

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

func Map Uses

func Map() map[string]interface{}

Return config as a map

func Scan Uses

func Scan(v interface{}) error

Scan values to a go type

func Sync Uses

func Sync() error

Force a source changeset sync

type Config Uses

type Config interface {
    // provide the reader.Values interface
    reader.Values
    // 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 Uses

func NewConfig(opts ...Option) (Config, error)

NewConfig returns new config

type Option Uses

type Option func(o *Options)

func WithLoader Uses

func WithLoader(l loader.Loader) Option

WithLoader sets the loader for manager config

func WithReader Uses

func WithReader(r reader.Reader) Option

WithReader sets the config reader

func WithSource Uses

func WithSource(s source.Source) Option

WithSource appends a source to list of sources

type Options Uses

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

    // for alternative data
    Context context.Context
}

type Watcher Uses

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

Watcher is the config watcher

func Watch Uses

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

Watch a value for changes

Directories

PathSynopsis
cmdPackage cmd is an interface for parsing the command line
encoderPackage encoder handles source encoding formats
encoder/hcl
encoder/json
encoder/toml
encoder/xml
encoder/yaml
loaderpackage loader manages loading from multiple sources
loader/memory
optionsPackage options provides a way to initialise options
readerPackage reader parses change sets and provides config values
reader/json
sourcePackage source is the interface for sources
source/cli
source/env
source/etcd
source/filePackage file is a file source.
source/flag
source/memoryPackage memory is a memory source
source/service
source/service/proto

Package config imports 10 packages (graph) and is imported by 30 packages. Updated 2020-02-13. Refresh now. Tools for package owners.