config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_LOG_LEVEL = "info"
	DEFAULT_PORT      = 8080
	DEFAULT_CACHE     = time.Duration(5 * time.Minute)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LogLevel     string        `yaml:"logLevel,omitempty"`
	Port         int           `yaml:"port,omitempty"`
	Cache        time.Duration `yaml:"cache,omitempty"`
	SpeedtestCLI string        `yaml:"speedtestCLI,omitempty"`
	Remote       RemoteConfig  `yaml:"remote,omitempty"`
}

func DefaultConfig

func DefaultConfig() Config

Returns a Config with default values set

func LoadConfig

func LoadConfig(path string, env bool) (Config, error)

Loads config from file, returns error if config is invalid Arguments:

path: Path to config file
mode: Mode used, determines how the config will be validated and which values will be processed
env: Determines if enviroment variables in the file will be expanded before decoding

type ErrInvalidInterval

type ErrInvalidInterval struct {
	Interval time.Duration
}

func (*ErrInvalidInterval) Error

func (e *ErrInvalidInterval) Error() string

type ErrUnknownLogLevel

type ErrUnknownLogLevel struct {
	Level string
}

func (*ErrUnknownLogLevel) Error

func (e *ErrUnknownLogLevel) Error() string

type RemoteConfig

type RemoteConfig struct {
	Enable   bool   `yaml:"enable"`
	URL      string `yaml:"url"`
	Instance string `yaml:"instance"`
	Username string `yaml:"username,omitempty"`
	Password string `yaml:"password,omitempty"`
}

Jump to

Keyboard shortcuts

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