Documentation ¶
Index ¶
- Constants
- func Apply(keyFunc KeyFunc, valueFunc ValueFunc, handler cfg.Handler) cfg.Handler
- func ApplyKey(keyFunc KeyFunc, handler cfg.Handler) cfg.Handler
- func ApplyValue(valueFunc ValueFunc, handler cfg.Handler) cfg.Handler
- func ByName(handlers ...*HandlerName) cfg.Handler
- func Env() cfg.Handler
- func EnvUpper() cfg.Handler
- func Loader(loader cfg.Loader) cfg.Handler
- func LowercaseKey(handler cfg.Handler) cfg.Handler
- func Map() cfg.Handler
- func MapUse(values map[string]interface{}) cfg.Handler
- func Multi(handlers ...cfg.Handler) cfg.Handler
- func PrefixKey(handler cfg.Handler, prefix string) cfg.Handler
- func Prioritized(handlers ...*HandlerName) cfg.Handler
- func Sync(handler cfg.Handler) *syncHandler
- func UppercaseKey(handler cfg.Handler) cfg.Handler
- func Viper(loader cfg.Loader) cfg.Handler
- func ViperCaseSensitive(loader cfg.Loader) cfg.Handler
- func ViperEx(loader cfg.Loader) cfg.Handler
- func ViperExCaseSensitive(loader cfg.Loader) cfg.Handler
- type HandlerName
- type HandlerNames
- type HotSwapHandler
- func (h *HotSwapHandler) Args() bool
- func (h *HotSwapHandler) Get(key string, args ...interface{}) (interface{}, error)
- func (h *HotSwapHandler) Init() error
- func (h *HotSwapHandler) Set(key string, value interface{}, args ...interface{}) error
- func (h *HotSwapHandler) SwapHandler(newHandler cfg.Handler)
- func (h *HotSwapHandler) SwapHandlerInit(newHandler cfg.Handler) error
- type KeyFunc
- type ValueFunc
Constants ¶
const ( // Default Use the default handler Default = "Default" // Override Use the Override handler Override = "Override" // Environment Use the environment handler Environment = "Environment" // Ini Use the ini handler Ini = "Ini" )
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply creates a new Apply Handler. An Apply handler applies the given key and value funcs to the key/value before calling the underlying handler. The funcs are only called if they aren't nil.
An Apply handler can be used to transform values. For example, if keys should always be in lower case you can apply a key func to lower case the keys.
func ApplyValue ¶
ApplyValue creates a new Apply handler with the specified ValueFunc.
func ByName ¶
func ByName(handlers ...*HandlerName) cfg.Handler
ByName creates a new handler that maps a list of handlers to their name. You can then do get and set operations against a named handler.
func EnvUpper ¶
EnvUpper returns a Env handler that first upper cases all keys before getting or setting them.
func LowercaseKey ¶
LowercaseKey creates a new Apply handler that lower cases all keys.
func Map ¶
Map creates a handler that stores all values in a hashmap. It is commonly used as a component to build more complex handlers.
func Multi ¶
Multi takes a list of Handlers and returns a single Handler that calls them. The handlers are called in the order they are specified.
func Prioritized ¶
func Prioritized(handlers ...*HandlerName) cfg.Handler
Prioritized creates a new Prioritized Handler. A Prioritized Handler performs look ups in the order they were given. In addition the name of a handler can be passed as the last argument to a set or get. If this is done, then the named handler is used.
func Sync ¶
Sync creates a Handler that can be safely accessed by multiple threads. It ensures that the Init method only initializes a handler one time, regardless of the number of threads that call it.
func UppercaseKey ¶
UppercaseKey creates a new Apply handler that upper cases all keys.
func ViperCaseSensitive ¶
ViperCaseSensitive implements github.com/spf13/viper except that keys are case sensitive.
Types ¶
type HandlerName ¶
A HandlerName associates a name with a given handler.
func NameHandler ¶
func NameHandler(name string, handler cfg.Handler) *HandlerName
NameHandler is a convenience function for creating new instances of a HandlerName type.
type HandlerNames ¶
type HandlerNames []*HandlerName
HandlerNames is list of HandlerName. The type allows us to add convenience functions to lists of HandlerName.
func (HandlerNames) ToHandlers ¶
func (hns HandlerNames) ToHandlers() []cfg.Handler
ToHandlers returns the handlers in an array of HandlerName.
func (HandlerNames) ToMap ¶
func (hns HandlerNames) ToMap() map[string]*HandlerName
ToMap returns a map from an array of HandlerName.
func (HandlerNames) ToNames ¶
func (hns HandlerNames) ToNames() []string
ToNames returns the name in an arry of HandlerName.
type HotSwapHandler ¶
type HotSwapHandler struct {
// contains filtered or unexported fields
}
HotSwapHandler holds a swappable handler. It is safe to swap this handler at run even if used by multiple threads.
func HotSwap ¶
func HotSwap(handler cfg.Handler) *HotSwapHandler
HotSwap creates a hot swappable handler.
func (*HotSwapHandler) Args ¶
func (h *HotSwapHandler) Args() bool
Args returns true if the underlying handler supports multiple args. It is thread safe.
func (*HotSwapHandler) Get ¶
func (h *HotSwapHandler) Get(key string, args ...interface{}) (interface{}, error)
Get retrieves key values. It is thread safe.
func (*HotSwapHandler) Init ¶
func (h *HotSwapHandler) Init() error
Init initializes the handler. It is thread safe.
func (*HotSwapHandler) Set ¶
func (h *HotSwapHandler) Set(key string, value interface{}, args ...interface{}) error
Set sets a key to a value. It is thread safe.
func (*HotSwapHandler) SwapHandler ¶
func (h *HotSwapHandler) SwapHandler(newHandler cfg.Handler)
SwapHandler allows a handler to be swapped in a thread safe fashion. You need to call init before using the handler.
func (*HotSwapHandler) SwapHandlerInit ¶
func (h *HotSwapHandler) SwapHandlerInit(newHandler cfg.Handler) error
SwapHandlerInit allows a handler to be swapped in a thread safe fashion. It also calls Init and returns the result.