config

package
v0.0.0-...-b09f343 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Development is string literal for dev environments
	Development = "DEVELOPMENT"
	// Test is string literal for test environments
	Test = "TEST"
	// Production is string literal for prod environments
	Production = "PRODUCTION"
)

Variables

This section is empty.

Functions

func IsProd

func IsProd(c *Config) bool

IsProd indicates whether server under production configuration

func ParseOverrides

func ParseOverrides(c interface{}, opts map[string]string) error

ParseOverrides overrides values in the config struct with environment variables and values passed from os.Args through opts

Types

type Config

type Config struct {
	Env string `yaml:"env" env:"ENV" cli:"env"`

	Net struct {
		Static   string `yaml:"static" env:"STATIC" cli:"static"`
		IP       string `yaml:"ip" env:"IP" cli:"ip"`
		Port     string `yaml:"port" env:"PORT" cli:"port"`
		Liveness int    `yaml:"liveness" env:"liveness" cli:"liveness"`
	}

	Timeout struct {
		Read  int `yaml:"read" env:"READ_TIMEOUT" cli:"read-timeout"`
		Write int `yaml:"write" env:"WRITE_TIMEOUT" cli:"write-timeout"`
		Stop  int `yaml:"stop" env:"STOP_TIMEOUT" cli:"stop-timeout"`
		Idle  int `yaml:"idle" env:"IDLE_TIMEOUT" cli:"idle-timeout"`
	}

	AWS struct {
		Region   string `yaml:"region" env:"AWS_REGION" cli:"region"`
		DynamoDB struct {
			Endpoint        string `yaml:"endpoint" env:"DB_ENDPOINT" cli:"db-endpoint"`
			PaginationLimit int64  `yaml:"pagination_limit" env:"PAGINATION" cli:"db-pagination"`
			Table           Tables
		}
	}
}

Config manages the configuration options of the program. Program options are configured first attempting to locate and open `httpd.yml`, first in the path specified by `QAAS_CONFIG` then in /etc/qaas Default values given in config are overriden by env var specified under the `env:"<VAL>"` attribute tags, and then by cli flags specified under the `cli:"<VAL"` attribute tag

func New

func New(opt ...Opts) (*Config, error)

New constructs and returns a configuration with the specified options

type Opts

type Opts func(c *Config) (*Config, error)

Opts is the type signature for optional configuration functions

func Update

func Update(options []string) Opts

Update accepts the os.Args array and overrides the Config, first with available env vars then with cli options

func WithFile

func WithFile(open func(string) (types.AFSFile, error)) Opts

WithFile locates and parses the config file into the Config struct. Prefers file path given by `QAAS_CONFIG` environment variable, defaults to /etc/qaas/httpd.yml

type Tables

type Tables struct {
	Quote  string `yaml:"quote" env:"QUOTE_TABLE" cli:"quote-table"`
	Author string `yaml:"author" env:"AUTHOR_TABLE" cli:"author-table"`
	Topic  string `yaml:"topic" env:"TOPIC_TABLE" cli:"topic-table"`
}

Tables represent the DynamoDB tables of the QAAS service

Jump to

Keyboard shortcuts

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