config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BotConfiguration

type BotConfiguration struct {
	Token      string `yaml:"token" json:"token" env:"TOKEN,required"`
	Name       string `yaml:"name" json:"name" env:"NAME,default=tgbot"`
	HelloWorld string `yaml:"hello_world" json:"hello_world" env:"HELLO_WORLD,default=Hello World"`
}

type Configuration

type Configuration struct {
	Bot        BotConfiguration        `yaml:"bot" json:"bot" env:"BOT,prefix=BOT_"`
	Repository RepositoryConfiguration `yaml:"repository" json:"repository" env:"REPOSITORY,prefix=REPOSITORY_"`
	Logging    LoggerConfiguration     `yaml:"logging" json:"logging" env:"LOGGING,prefix=LOGGING_"`
}

Configuration is the configuration of the bot.

func CreateConfigurationFromEnv

func CreateConfigurationFromEnv(prefix string) (cfg *Configuration, err error)

func CreateConfigurationFromEnvFile

func CreateConfigurationFromEnvFile(prefix string, filenames ...string) (cfg *Configuration, err error)

func CreateConfigurationFromFile

func CreateConfigurationFromFile(filename string) (cfg *Configuration, err error)

func (*Configuration) FixDefaults

func (cfg *Configuration) FixDefaults() *Configuration

FixDefaults checks and fixes the configuration of defaults values.

type LoggerConfiguration

type LoggerConfiguration struct {
	Level           string       `yaml:"level" json:"level" env:"LEVEL,default=info"`
	FormatTimeStamp string       `yaml:"format_time_stamp" json:"format_time_stamp" env:"FORMAT_TIME_STAMP,default=2006-01-02 15:04:05"`
	Format          string       `yaml:"log_format" json:"log_format" env:"LOG_FORMAT,default=%time% %lvl% [%name%] %msg%\n"`
	LogLevel        logrus.Level `yaml:"-" json:"-"`
}

LoggerConfiguration is the configuration for the logger

func (*LoggerConfiguration) FixDefaults

func (cfg *LoggerConfiguration) FixDefaults() LoggerConfiguration

type RepositoryConfiguration

type RepositoryConfiguration struct {
	ConnectionString   string        `yaml:"connection_string" json:"connection_string" env:"CONNECTION_STRING"`
	HouseKeepingMaxAge time.Duration `json:"house_keeping_max_age" yaml:"house_keeping_max_age" env:"HOUSE_KEEPING_MAX_AGE"`
}

Jump to

Keyboard shortcuts

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