config

package
v0.0.0-...-efb4e53 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 8 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 {
	Service    ServiceConfig
	HttpServer HttpServerConfig
}

func GetConfig

func GetConfig(configFileDirName string) *Config

Returns config from a file or environment variables. Env vars have priority if they exist.

type HttpServerConfig

type HttpServerConfig struct {
	Hostname          string          `toml:"hostname" env:"HTTPSERVER_HOSTNAME" env-required`
	HostPort          int             `toml:"host_port" env:"HTTPSERVER_HOST_PORT" env-required`
	ReadHeaderTimeout StrTimeDuration `toml:"read_header_timeout_duration" env:"HTTPSERVER_READ_HEADER_TIMEOUT_DURATION" env-required`
	WriteTimeout      StrTimeDuration `toml:"write_timeout_duration" env:"HTTPSERVER_WRITE_TIMEOUT_DURATION" env-required`
}

type ServiceConfig

type ServiceConfig struct {
	TimeBetweenJobProcesses StrTimeDuration `toml:"time_between_job_processes" env:"QUEUE_MGR_TIME_BTW_JOB_PROCESSES" env-required`
}

type StrTimeDuration

type StrTimeDuration string

Purpose: 1) Reap the benefit of being able to use time duration string format in config variables. 2) Validate format when parsing the config file / env var and not having to do it always before passing each value of the type to a builder or contructor func.

func (*StrTimeDuration) GetDuration

func (d *StrTimeDuration) GetDuration() time.Duration

func (*StrTimeDuration) SetValue

func (d *StrTimeDuration) SetValue(s string) error

Implements Setter interface needed by library cleanenv to set the custom type

Jump to

Keyboard shortcuts

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