config

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2017 License: MIT Imports: 10 Imported by: 6

Documentation

Overview

Package config implements logic to load dynamic configuration from various sources It also defines environment specific configuration (dev, prod, ...)

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 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

Types

type AdapterConfig added in v0.3.0

type AdapterConfig struct {
	Adapter string            `json:"adapter"`
	Config  map[string]string `json:"config"`
}

AdapterConfig is a generic config struct for adapters

type Config

type Config struct {
	Node    string      `json:"node"`
	Version string      `json:"version"`
	Request Request     `json:"request"`
	Log     Log         `json:"log"`
	Stats   Stats       `json:"stats"`
	App     interface{} `json:"app"`
}

Config defines the app config

type Log

type Log struct {
	Level     string        `json:"level"`
	Formatter AdapterConfig `json:"formatter"`
	Printer   AdapterConfig `json:"printer"`
}

Log contains all log-related configuration

type Request

type Request struct {
	TimeoutMS    time.Duration `json:"timeout_ms"`
	AllowContext bool          `json:"allow_context"`
	Panic        bool          `json:"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 Stats

type Stats struct {
	On      bool              `json:"on"`
	Adapter string            `json:"adapter"`
	Config  map[string]string `json:"config"`
}

Stats contains all stats-related configuration

Directories

Path Synopsis
consul
Package consul reads configuration from the Consul KV store Consul is a highly available and distributed service discovery and key-value store designed with support for the modern data center to make distributed systems and configuration easy.
Package consul reads configuration from the Consul KV store Consul is a highly available and distributed service discovery and key-value store designed with support for the modern data center to make distributed systems and configuration easy.
file
Package file reads configuration from a JSON file e.g.
Package file reads configuration from a JSON file e.g.

Jump to

Keyboard shortcuts

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