config

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSettings = make(map[string]interface{})
View Source
var (

	// ErrConfigAlreadyLoaded ошибка, говорящая о том, что конфигурация уже загружена
	ErrConfigAlreadyLoaded = errors.New("config already loaded")
)

Functions

func AddSubscriber added in v1.0.3

func AddSubscriber(nch chan struct{}) error

AddSubscriber функция, которая добавляет подписчиков на рассылку уведомлений в момент, когда конфигурация приложения будет загружена. Возвращает ошибку, если конфигурация уже загружена NOTE: полезна для lazyLoad драйверов

func LoadConfig

func LoadConfig(filepath string) error

LoadConfig the main function for load config

Types

type AppConfig

type AppConfig struct {
	Debug             bool   `yaml:"debug"`
	TGBotToken        string `yaml:"tg_bot_token"`
	PathToIDRSA       string `yaml:"path_to_id_rsa"        validate:"required,file"`
	Port              int    `yaml:"port"                  validate:"required"`
	MaxLocalLogSizeMB int    `yaml:"max_local_log_size_mb" validate:"required"`
	NumberRowsToLoad  int    `yaml:"number_rows_to_load"   validate:"required"`
	Auth              bool   `yaml:"auth"`
}

type Config

type Config struct {
	App      AppConfig           `yaml:"app"`
	Defaults DefaultServerConfig `yaml:"default_servers_setting"`
	Servers  []ServerConfig      `yaml:"servers"`
}
var Cfg Config

type DefaultServerConfig

type DefaultServerConfig struct {
	StartLine     string   `yaml:"start_line"`
	LogDir        string   `yaml:"log_dir"`
	LogLayout     string   `yaml:"log_layout"`
	LogLevel      string   `yaml:"log_levels"`
	LogTimeFormat string   `yaml:"log_time_format"`
	Recipients    []string `yaml:"recipients"`
	// none or notification driver name (if not found => none)
	Notify string `yaml:"notify"`
}

type ServerConfig

type ServerConfig struct {
	ID            int      `yaml:"id"              validate:"required"`
	Enabled       bool     `yaml:"enabled"`
	Name          string   `yaml:"name"            validate:"required"`
	Host          string   `yaml:"host"            validate:"-"`
	User          string   `yaml:"user"            validate:"-"`
	Port          int      `yaml:"port"            validate:"-"`
	LogDir        string   `yaml:"log_dir"         validate:"required"`
	LogDriver     string   `yaml:"log_driver"      validate:"-"`
	LogLayout     string   `yaml:"log_layout"      validate:"required"`
	LogLevel      string   `yaml:"log_levels"      validate:"required"`
	LogTimeFormat string   `yaml:"log_time_format" validate:"required"`
	StartLine     string   `yaml:"start_line"      validate:"required"`
	Recipients    []string `yaml:"recipients"      validate:"required"`
	Notify        string   `yaml:"notify"          validate:"-"`
	IsLocal       bool     `yaml:"is_local"        validate:"checkHUP"`
}

Jump to

Keyboard shortcuts

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