provider

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CommaSeparator = ","
View Source
const (
	ErrJsonInvalidSource = utils.Error("NewJsonProvider: Invalid source type")
)

Variables

View Source
var DefaultSeparator = CommaSeparator

Functions

func NewJsonProvider

func NewJsonProvider(src interface{}) (config.ConfigInterface, error)

Types

type EnvProvider

type EnvProvider struct {
	config.ConfigInterface
	// contains filtered or unexported fields
}

func NewEnvProvider

func NewEnvProvider(prefix string, convertCamelCase bool) *EnvProvider

NewEnvProvider builds a new config.ConfigInterface object from system Environment variables. The parameter prefix defines the key prefix to use. All existing Environment variables matching the prefix are loaded on creation. If convertCamelCase is enabled, string keys are automatically converted from camelCase format to SNAKE_CASE

func (*EnvProvider) GetBoolKey

func (e *EnvProvider) GetBoolKey(key string) (bool, error)

func (*EnvProvider) GetConfigNode

func (e *EnvProvider) GetConfigNode(key string) (config.ConfigInterface, error)

func (*EnvProvider) GetFloat64Key

func (e *EnvProvider) GetFloat64Key(key string) (float64, error)

func (*EnvProvider) GetIntKey

func (e *EnvProvider) GetIntKey(key string) (int, error)

func (*EnvProvider) GetKey

func (e *EnvProvider) GetKey(key string, dest interface{}) error

GetKey reads an env key to an interface. if dest is a pointer to a struct, key is used as a prefix, and it will attempt to extract prefix+fieldName or prefix+field_env into the different struct fields. if dest is a valid type and key is a valid env var, it will extract the env value into the var.

func (*EnvProvider) GetSliceKey

func (e *EnvProvider) GetSliceKey(key, separator string) ([]string, error)

func (*EnvProvider) GetStringKey

func (e *EnvProvider) GetStringKey(key string) (string, error)

func (*EnvProvider) KeyExists

func (e *EnvProvider) KeyExists(key string) bool

func (*EnvProvider) KeyListExists

func (e *EnvProvider) KeyListExists(keys []string) bool

type JsonProvider

type JsonProvider struct {
	config.ConfigInterface
	// contains filtered or unexported fields
}

func (*JsonProvider) GetBoolKey

func (j *JsonProvider) GetBoolKey(key string) (bool, error)

func (*JsonProvider) GetConfigNode

func (j *JsonProvider) GetConfigNode(key string) (config.ConfigInterface, error)

func (*JsonProvider) GetFloat64Key

func (j *JsonProvider) GetFloat64Key(key string) (float64, error)

func (*JsonProvider) GetIntKey

func (j *JsonProvider) GetIntKey(key string) (int, error)

func (*JsonProvider) GetKey

func (j *JsonProvider) GetKey(key string, dest interface{}) error

func (*JsonProvider) GetSliceKey

func (j *JsonProvider) GetSliceKey(key, separator string) ([]string, error)

GetSliceKey note: separator is ignored

func (*JsonProvider) GetStringKey

func (j *JsonProvider) GetStringKey(key string) (string, error)

func (*JsonProvider) KeyExists

func (j *JsonProvider) KeyExists(key string) bool

func (*JsonProvider) KeyListExists

func (j *JsonProvider) KeyListExists(keys []string) bool

Jump to

Keyboard shortcuts

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