config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package config implements logic to load dynamic configuration from various sources

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adapters

func Adapters() []string

Adapters returns the list of registered adapters

func NewStore

func NewStore(configStoreURI string) (store.Store, error)

NewStore returns a loaded config store defined by the ConfigStorage env

func Register

func Register(name string, adapter store.Adapter)

Register makes a store adapter available by the provided name. If an adapter is registered twice or if an adapter is nil, it will panic.

func TreeWithContext

func TreeWithContext(ctx context.Context, t Tree) context.Context

TreeWithContext returns a copy of parent in which the `Tree` is stored

func ValueOf

func ValueOf(s string) string

ValueOf extracts the environment variable name given or the plain string given

e.g. foo -> foo

$DATABASE_URL -> http://foo.bar:8083

func ValuesOf

func ValuesOf(v interface{}) interface{}

ValuesOf extracts the environment variable(s) from v

Types

type Config

type Config struct {
	Node    string  `toml:"node"`
	Version string  `toml:"version"`
	Request Request `toml:"request"`
}

Config defines the app config

type Request

type Request struct {
	TimeoutMS    time.Duration `toml:"timeout_ms"`
	AllowContext bool          `toml:"allow_context"`
	Panic        bool          `toml:"panic"`
}

Request defines the request default configuration

func (*Request) Timeout

func (r *Request) Timeout() time.Duration

Timeout returns the TimeoutMS field in time.Duration

type Tree

type Tree interface {
	Keys() []string
	Has(key string) bool
	Get(key string) Tree
	Unmarshal(v interface{}) error
	String() string
}

Tree is a configuration tree

func LoadTree

func LoadTree(r io.Reader) (Tree, error)

LoadTree loads r into a config tree

func NopTree

func NopTree() Tree

NopTree returns an empty tree

func TreeFromContext

func TreeFromContext(ctx contextutil.ValueContext) Tree

TreeFromContext returns a config `Tree` instance associated with `ctx`, or a `NopTree` if no `Tree` instance could be found.

func TreeFromMap

func TreeFromMap(m map[string]interface{}) (Tree, error)

TreeFromMap initialises a new Tree object using the given map.

Directories

Path Synopsis
consul
Package consul reads configuration from the Consul KV store
Package consul reads configuration from the Consul KV store
file
Package file reads configuration from a JSON file
Package file reads configuration from a JSON file

Jump to

Keyboard shortcuts

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