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.


Package Files

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


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
    // Init the config
    Init(opts ...Option) error
    // 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


cmdPackage cmd is an interface for parsing the command line
encoderPackage encoder handles source encoding formats
loaderpackage loader manages loading from multiple sources
optionsPackage options provides a way to initialise options
readerPackage reader parses change sets and provides config values
secretsPackage secrets is an interface for encrypting and decrypting secrets
secrets/boxPackage box is an asymmetric implementation of config/secrets using nacl/box
secrets/secretboxPackage secretbox is a config/secrets implementation that uses nacl/secretbox to do symmetric encryption / verification
sourcePackage source is the interface for sources
source/filePackage file is a file source.
source/memoryPackage memory is a memory source

Package config imports 10 packages (graph) and is imported by 18 packages. Updated 2020-03-26. Refresh now. Tools for package owners.