config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: BSD-3-Clause Imports: 5 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 {
	Maintenance  bool                `default:"false" yaml:"maintenance"`
	Mode         string              `default:"release"`
	LogLevel     logger.LevelDecoder `split_words:"true" default:"info" yaml:"log_level"`
	ConsoleLog   bool                `split_words:"true" default:"false" yaml:"console_log"`
	BindAddr     string              `split_words:"true" default:":8765" yaml:"bind_addr"`
	AllowOrigins []string            `split_words:"true" default:"http://localhost:8765"`
	// contains filtered or unexported fields
}

Config contains all of the configuration parameters for an rtnl server and is loaded from the environment or a configuration file with reasonable defaults for values that are omitted. The Config should be validated in preparation for running the server to ensure that all server operations work as expected.

func New

func New() (conf Config, err error)

New creates and processes a Config from the environment ready for use. If the configuration is invalid or it cannot be processed an error is returned.

func (Config) GetLogLevel

func (c Config) GetLogLevel() zerolog.Level

Parse and return the zerolog log level for configuring global logging.

func (Config) IsZero

func (c Config) IsZero() bool

A Config is zero-valued if it hasn't been processed by a file or the environment.

func (Config) Mark

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

Mark a manually constructed config as processed as long as its valid.

func (Config) Validate

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

Validates the config is ready for use in the application and that configuration semantics such as requiring multiple required configuration parameters are enforced.

Jump to

Keyboard shortcuts

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