Documentation ¶
Overview ¶
Package config contains convenience functions for reading and managing viper configs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cacher ¶ added in v0.8.0
type Cacher struct {
// contains filtered or unexported fields
}
Cacher is used to cache the construction of an object, such as a connection. It will detect which config values are read when constructing the object. Then, when further requests are made, it will return the same object as long as the config values which were used haven't changed.
func NewCacher ¶ added in v0.8.0
func NewCacher(cfg View, newInstance NewInstanceFunc) *Cacher
NewCacher returns a cacher which uses cfg to detect relevant changes, and newInstance to construct the object when nessisary. newInstance MUST use the provided View when constructing the object.
func (*Cacher) ForceReset ¶ added in v0.8.0
func (c *Cacher) ForceReset()
ForceReset causes Cacher to forget the cached object. The next call to Get will again use newInstance to create a new object.
func (*Cacher) Get ¶ added in v0.8.0
Get returns the cached object if possible, otherwise it calls newInstance to construct the new cached object. When Get is next called, it will detect if any of the configuration values which were used to construct the object have changed. If they have, the cache is invalidated, and a new object is constructed. If newInstance returns an error, Get returns that error and the object will not be cached or returned.
type NewInstanceFunc ¶ added in v0.9.0
NewInstanceFunc is used by the cacher to create a new value given the config. It may return an additional function to close or otherwise cleanup if ForceReset is called.
type View ¶
type View interface { IsSet(string) bool GetString(string) string GetInt(string) int GetInt64(string) int64 GetFloat64(string) float64 GetStringSlice(string) []string GetBool(string) bool GetDuration(string) time.Duration }
View is a read-only view of the Open Match configuration. New accessors from Viper should be added here.