config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureLogging

func ConfigureLogging(config *LoggingConfig) (*logrus.Entry, error)

ConfigureLogging configures the default logger

Types

type CacheConfiguration

type CacheConfiguration struct {
	NumCounters int64 `json:"num_counters" envconfig:"CACHE_NUM_COUNTERS"`
	MaxCosts    int64 `json:"max_costs" envconfig:"CACHE_MAX_COSTS"`
	BufferItems int64 `json:"buffer_items" envconfig:"CACHE_BUFFER_ITEMS"`
	Metrics     bool  `json:"metrics" envconfig:"CACHE_METRICS"`
}

CacheConfiguration maps config for ristretto cache

type Configuration

type Configuration struct {
	Logging     LoggingConfig            `json:"log"`
	DB          DBConfiguration          `json:"db"`
	OpenWeather OpenWeatherConfiguration `json:"open_weather"`
	Web         WebConfiguration         `json:"web"`
	Cache       CacheConfiguration       `json:"cache"`
}

Configuration holds information about our current application-instance the config data SHOULD be loaded from environment variables

func LoadConfig

func LoadConfig(filename string) (*Configuration, error)

LoadConfig loads the Configuration from env

type DBConfiguration

type DBConfiguration struct {
	Driver    string `json:"driver" required:"true" envconfig:"DATABASE_DRIVER"`
	URL       string `json:"url" envconfig:"DATABASE_URL" required:"true"`
	Namespace string `json:"namespace" envconfig:"DATABASE_NAMESPACE"`
}

DBConfiguration connection params for our Database

type LoggingConfig

type LoggingConfig struct {
	Level            string                 `mapstructure:"log_level" json:"log_level" envconfig:"LOG_LEVEL"`
	File             string                 `mapstructure:"log_file" json:"log_file" envconfig:"LOG_FILE"`
	DisableColors    bool                   `mapstructure:"disable_colors" split_words:"true" json:"disable_colors" envconfig:"LOG_DISABLE_COLORS"`
	QuoteEmptyFields bool                   `mapstructure:"quote_empty_fields" split_words:"true" json:"quote_empty_fields" envconfig:"LOG_QUOTE_EMPTY_FIELDS"`
	TSFormat         string                 `mapstructure:"ts_format" json:"ts_format"`
	Fields           map[string]interface{} `mapstructure:"fields" json:"fields"`
}

LoggingConfig keeps logrus Configuration

type OpenWeatherConfiguration

type OpenWeatherConfiguration struct {
	APIKEY           string `json:"api_key" required:"true" envconfig:"OPENWEATHER_API_KEY"`
	CityListEndpoint string `json:"city_list_endpoint" envconfig:"OPENWEATHER_CITYLIST_ENDPOINT"`
	Fallback         bool   `json:"fallback" envconfig:"OPENWEATHER_FALLBACK"`
}

OpenWeatherConfiguration keeps track of openweather informations

type WebConfiguration

type WebConfiguration struct {
	UseTLS     bool   `json:"tls" envconfig:"WEB_USE_TLS"`
	ListenAddr string `json:"-"  envconfig:"WEB_LISTEN_ADDR"`
	BaseURL    string `json:"-"`
	Debug      bool   `json:"debug" envconfig:"WEB_DEBUG"`
}

WebConfiguration keeps information for our WebService

Jump to

Keyboard shortcuts

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