environment

package
v2.18.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const NoS3EnvVar = "NO_S3_ENV_VARS"

NoS3EnvVar is the environment variable to set when you so not want to try and pull from S3.

Variables

This section is empty.

Functions

func Get

func Get(key string, defaultVal string) string

Get returns the value of an environment variable if the variable is set, else the default value

func GetEnvMap

func GetEnvMap() map[string]string

GetEnvMap returns a map of all environment variables to their values

func NewInvalidSpecificationError

func NewInvalidSpecificationError() errors.TracerError

NewInvalidSpecificationError instantiates a InvalidSpecificationError with a stack trace

func NewMissingEnvironmentVariableError

func NewMissingEnvironmentVariableError(field string, tag string) errors.TracerError

NewMissingEnvironmentVariableError instantiates a MissingEnvironmentVariableError with a stack trace

func NewUnsupportedDataTypeError

func NewUnsupportedDataTypeError(dataType reflect.Kind, field string) errors.TracerError

NewUnsupportedDataTypeError instantiates a UnsupportedDataTypeError with a stack trace

func Process

func Process(config interface{}, logger log.Logger) error

Process takes a Specification that describes the configuration for the application only attributes tagged with `env:""` will be imported from the environment Example Specification:

type Specification struct {
    DatabaseURL string `env:"DATABASE_URL"`
    ServiceID   string `env:"SERVICE_ID,optional"`
}

Supported options: optional

func ProcessMap

func ProcessMap(config interface{}, envVars map[string]string, logger log.Logger) error

ProcessMap is the same as Process except that the environment variable map is supplied instead of retrieved

func Push

func Push(config interface{}) error

Push the passed specification object onto the environment, note that these changes will not live past the life of this process.

func RedisAddress

func RedisAddress() string

RedisAddress returns the combined host and port from the environment

func RedisHost

func RedisHost() string

RedisHost returns the host value from the environment

func RedisPort

func RedisPort() int

RedisPort returns the port value from the environment

Types

type Bucket

type Bucket struct {
	Downloader *s3manager.Downloader
	// contains filtered or unexported fields
}

Bucket wraps the S3 downloader with an in memory cache

func NewBucket

func NewBucket() *Bucket

NewBucket returns a Bucket with an S3 downloader and an initialized cache

func (*Bucket) Add

func (b *Bucket) Add(bucket, item string, data map[string]interface{})

Add a map of data from S3 to the cache

func (*Bucket) Get

func (b *Bucket) Get(bucket, item, key string, logger log.Logger) interface{}

Get pulls a value from a map loaded from and S3 bucket

func (*Bucket) Has

func (b *Bucket) Has(bucket, item, key string) (interface{}, bool)

Has checks for a given key in the cache

type InvalidSpecificationError

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

InvalidSpecificationError indicates that a config is of the wrong type.

func (*InvalidSpecificationError) Error

func (err *InvalidSpecificationError) Error() string

func (*InvalidSpecificationError) Trace

func (err *InvalidSpecificationError) Trace() []string

Trace returns the stack trace for the error

type MissingEnvironmentVariableError

type MissingEnvironmentVariableError struct {
	Field string
	Tag   string
	// contains filtered or unexported fields
}

MissingEnvironmentVariableError indicates that a non-optional variable was not found in the environment

func (MissingEnvironmentVariableError) Error

func (*MissingEnvironmentVariableError) Trace

func (err *MissingEnvironmentVariableError) Trace() []string

Trace returns the stack trace for the error

type UnsupportedDataTypeError

type UnsupportedDataTypeError struct {
	Type  reflect.Kind
	Field string
	// contains filtered or unexported fields
}

UnsupportedDataTypeError indicates that no conversion from string to the given type has been implemented

func (UnsupportedDataTypeError) Error

func (err UnsupportedDataTypeError) Error() string

func (*UnsupportedDataTypeError) Trace

func (err *UnsupportedDataTypeError) Trace() []string

Trace returns the stack trace for the error

Jump to

Keyboard shortcuts

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