config

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BindAddr       string              `split_words:"true" default:":8090"`
	Mode           string              `default:"release"`
	LogLevel       logger.LevelDecoder `split_words:"true" default:"info"`
	ConsoleLog     bool                `split_words:"true" default:"false"`
	AllowOrigins   []string            `split_words:"true" default:"http://localhost:8090"`
	StatusInterval time.Duration       `split_words:"true" default:"15s"`
	DataPath       string              `split_words:"true" default:".uptime"`
	ServiceInfo    string              `split_words:"true" required:"false"`
	// contains filtered or unexported fields
}

func New

func New() (conf Config, err error)

New loads and parses the config from the environment and validates it, marking it as processed so that external users can determine if the config is ready for use. This should be the only way Config objects are created for use in the application.

func (Config) GetLogLevel

func (c Config) GetLogLevel() zerolog.Level

func (Config) IsZero

func (c Config) IsZero() bool

Returns true if the config has not been correctly processed from the environment.

func (Config) Mark

func (c Config) Mark() (_ Config, err error)

Mark a manually constructed config as processed as long as it is valid.

func (Config) Validate

func (c Config) Validate() (err error)

Custom validations are added here, particularly validations that require one or more fields to be processed before the validation occurs. NOTE: ensure that all nested config validation methods are called here.

Jump to

Keyboard shortcuts

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