Documentation ¶
Overview ¶
Package storage provides the available storage engines for level 1 and level 2 caches.
Use Go build tags to enable special storage clients or file format loading functions. Supported tags are: bigcache (store in big cache), db (store in MySQL/MariaDB), etcdv3 (store in etcd cluster/server), load from json and yaml.
Index ¶
- Constants
- func FromEnvVar(prefix, envVar string) (*config.Path, error)
- func MakeMulti(o MultiOptions, ss ...config.Storager) config.Storager
- func NewLRU(maxEntries int) config.Storager
- func NewMap(fqPathValue ...string) config.Storager
- func ToEnvVar(p *config.Path) string
- func WithLoadEnvironmentVariables(op EnvOp) config.LoadDataOption
- func WithLoadStrings(fqPathValue ...string) config.LoadDataOption
- type EnvOp
- type MultiOptions
Constants ¶
const Prefix = "CONFIG" + SlashSeparator
Prefix with which an environment variable must begin with to be considered as a configuration value.
const SlashSeparator = "__"
SlashSeparator acts as a slash separator for environment keys.
Variables ¶
This section is empty.
Functions ¶
func FromEnvVar ¶
FromEnvVar parses an environment key into a config.Path.
CONFIG__ETCD__CREDENTIALS__USER_NAME => scope.DefaultTypeID, etc/credentials/user_name
func MakeMulti ¶
func MakeMulti(o MultiOptions, ss ...config.Storager) config.Storager
MakeMulti creates a new Multi backend wrapper. Supports other Multi backend wrappers.
func NewLRU ¶
NewLRU creates a new lruCache. If maxEntries is zero, the cache has no limit and it's assumed that eviction is done by the caller. This type does not get exported. WithLRU provides the `lru` cache which implements a fixed-size thread safe LRU cache. If maxEntries is zero, the cache has no limit and it's assumed that eviction is done by the caller. lru cache to limit the amount of request to the backend service. Use function WithLRU to enable it and set the correct max size of the LRU cache. For now this algorithm should be good enough. Can be refactored any time later.
func NewMap ¶
NewMap creates a new simple key value storage using a map. Mainly used for testing. fqPathValue must be a balanced slice where i=fully qualified path and i+1 the value.
func ToEnvVar ¶
ToEnvVar converts a Path to a valid environment key. Returns an empty string in case of an error.
scope.DefaultTypeID, etc/credentials/user_name => CONFIG__ETCD__CREDENTIALS__USER_NAME
func WithLoadEnvironmentVariables ¶
func WithLoadEnvironmentVariables(op EnvOp) config.LoadDataOption
WithLoadEnvironmentVariables reads configuration values from environment variables. A valid env var is always uppercase and [A-Z0-9_].
CONFIG__ETCD__CREDENTIALS__USER_NAME -> etc/credentials/user_name
Env vars (environment variables) can be unset after reading and optionally cached. They can be read during initialization of the storage backend or on each request.
func WithLoadStrings ¶
func WithLoadStrings(fqPathValue ...string) config.LoadDataOption
WithLoadStrings loads a balanced fully qualified path and its stringified value pair into the config.Service. It does not panic when the fqPathValue slice argument isn't balanced, but returns an error. This functional option allows to load immutable values.
Types ¶
type EnvOp ¶
type EnvOp struct { // Prefix can be set to as a custom optional Prefix in case where default // Prefix does not work. Prefix string }
EnvOp allows to set options when creating a new Environment storage service.
type MultiOptions ¶
type MultiOptions struct { // ContextTimeout if greater than zero a timeout will kick in. ContextTimeout time.Duration WriteDisabled []bool // TODO implement must be same length as `backends` and defines which backends should ne write WriteSerial bool // TODO implement ReadParallel bool // TODO implement }
MultiOptions provides options for function MakeMulti.