configuration

package
v0.0.0-...-7ff13f1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package configuration is in charge of the validation and extraction of all the configuration details from a configuration file or environment variables.

Index

Constants

View Source
const (
	// EnvPrefix will be used for environment variable name prefixing.
	EnvPrefix = "APP"

	// DefaultHTTPAddress is the address and port string that your service will
	// be exported to by default.
	DefaultHTTPAddress = "0.0.0.0:8080"

	// DefaultHTTPIdleTimeout specifies the default timeout for HTTP idling
	DefaultHTTPIdleTimeout = time.Second * 15

	// DefaultHTTPCompressResponses compresses HTTP responses for clients that
	// support it via the 'Accept-Encoding' header.
	DefaultHTTPCompressResponses = false

	// DefaultLogLevel is the default log level used in your service.
	DefaultLogLevel = "info"

	// DefaultLogJSON is a switch to toggle on and off JSON log output.
	DefaultLogJSON = false

	// DefaultGracefulTimeout is the duration for which the server gracefully
	// wait for existing connections to finish - e.g. 15s or 1m
	DefaultGracefulTimeout = time.Second * 15

	// DefaultHTTPWriteTimeout specifies the default timeout for HTTP writes
	DefaultHTTPWriteTimeout = time.Second * 15

	// DefaultHTTPReadTimeout specifies the default timeout for HTTP reads
	DefaultHTTPReadTimeout = time.Second * 15
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

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

Registry encapsulates the Viper configuration registry which stores the configuration data in-memory.

func New

func New(configFilePath string) (*Registry, error)

New creates a configuration reader object using a configurable configuration file path. If the provided config file path is empty, a default configuration will be created.

func (*Registry) GetGracefulTimeout

func (c *Registry) GetGracefulTimeout() time.Duration

GetGracefulTimeout returns the duration for which the server gracefully wait for existing connections to finish - e.g. 15s or 1m

func (*Registry) GetHTTPAddress

func (c *Registry) GetHTTPAddress() string

GetHTTPAddress returns the HTTP address (as set via default, config file, or environment variable) that the app-server binds to (e.g. "0.0.0.0:8080")

func (*Registry) GetHTTPCompressResponses

func (c *Registry) GetHTTPCompressResponses() bool

GetHTTPCompressResponses returns true if HTTP responses should be compressed for clients that support it via the 'Accept-Encoding' header.

func (*Registry) GetHTTPIdleTimeout

func (c *Registry) GetHTTPIdleTimeout() time.Duration

GetHTTPIdleTimeout returns the duration for which

func (*Registry) GetHTTPReadTimeout

func (c *Registry) GetHTTPReadTimeout() time.Duration

GetHTTPReadTimeout returns the duration for which

func (*Registry) GetHTTPWriteTimeout

func (c *Registry) GetHTTPWriteTimeout() time.Duration

GetHTTPWriteTimeout returns the duration for which

func (*Registry) GetLogLevel

func (c *Registry) GetLogLevel() string

GetLogLevel returns the loggging level (as set via config file or environment variable)

func (*Registry) IsLogJSON

func (c *Registry) IsLogJSON() bool

IsLogJSON returns if we should log json format (as set via config file or environment variable)

Jump to

Keyboard shortcuts

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