valuesloader

package
v0.0.0-...-2654a50 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValueLoaderFunc

type ValueLoaderFunc func(key string) (string, bool)

ValueLoaderFunc is called whenever the value for a given key is not present in the cache.

func AWSSecretsManagerLoader

func AWSSecretsManagerLoader(secretArn string) (ValueLoaderFunc, error)

func EnvironmentLoader

func EnvironmentLoader() (ValueLoaderFunc, error)

func JSONFileLoader

func JSONFileLoader(filepath string) (ValueLoaderFunc, error)

func JSONLoader

func JSONLoader(data []byte) (ValueLoaderFunc, error)

func RemoteJSONLoader

func RemoteJSONLoader(url string) (ValueLoaderFunc, error)

type ValuesLoader

type ValuesLoader struct {
	// contains filtered or unexported fields
}

ValuesLoader loads and caches values based on keys. It gets the values from the ValueLoaderFunc provided.

func New

func New(loaders ...ValueLoaderFunc) (*ValuesLoader, error)

New returns a new ValuesLoader instance or an error if the provided loader function is nil.

func (*ValuesLoader) Get

func (v *ValuesLoader) Get(key string) string

Get works just like Lookup but without returning the boolean flag.

func (*ValuesLoader) Lookup

func (v *ValuesLoader) Lookup(key string) (string, bool)

Loopup gets a value for a given key, it will first try to get the value from the cache, if it is not present in the cache it will call each ValueLoaderFunc in order. It returns true if the key was found, otherwise it returns false.

Jump to

Keyboard shortcuts

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