config

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

README

Config GoDoc

Go Config is a pluggable dynamic config library.

Most config in applications are statically configured or include complex logic to load from multiple sources. Go Config makes this easy, pluggable and mergeable. You'll never have to deal with config in the same way again.

Features

  • Dynamic - load config on the fly as you need it
  • Pluggable - choose which source to load from; file, env, consul
  • Mergeable - merge and override multiple config sources
  • Observable - Watch the config for changes
  • Safe - specify fallback values where keys don't exist

Getting Started

For detailed information or architecture, installation and general usage see the docs

Documentation

Overview

Package config is an interface for dynamic configuration.

Index

Constants

This section is empty.

Variables

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

Functions

func Bytes added in v0.6.0

func Bytes() []byte

Return config as raw json

func Get added in v0.6.0

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

Get a value from the config

func Load added in v0.6.0

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

Load config sources

func Map added in v0.6.0

func Map() map[string]interface{}

Return config as a map

func Scan added in v0.6.0

func Scan(v interface{}) error

Scan values to a go type

func Sync added in v0.6.0

func Sync() error

Force a source changeset sync

Types

type Config

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

func NewConfig(opts ...Option) Config

NewConfig returns new config

type Option

type Option func(o *Options)

func WithLoader added in v0.8.0

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 added in v0.6.0

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

Watch a value for changes

Directories

Path Synopsis
Package encoder handles source encoding formats
Package encoder handles source encoding formats
hcl
xml
package loader manages loading from multiple sources
package loader manages loading from multiple sources
Package reader parses change sets and provides config values
Package reader parses change sets and provides config values
Package source is the interface for sources
Package source is the interface for sources
configmap
Package configmap config is an interface for dynamic configuration.
Package configmap config is an interface for dynamic configuration.
env
file
Package file is a file source.
Package file is a file source.
grpc/proto
Package grpc is a generated protocol buffer package.
Package grpc is a generated protocol buffer package.
memory
Package memory is a memory source
Package memory is a memory source
runtimevar
package runtimevar is the source for github.com/google/go-cloud/runtimevar
package runtimevar is the source for github.com/google/go-cloud/runtimevar
url
Package url loads changesets from a url
Package url loads changesets from a url

Jump to

Keyboard shortcuts

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