config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	ExpTimeout   string `yaml:"expiration"`
	CleanTimeout string `yaml:"cleanup"`
	Expire       time.Duration
	Clean        time.Duration
}

func (*Cache) Options

func (cfg *Cache) Options() error

type Config

type Config struct {
	AppDir string
	Env    string

	ServerAdr string     `yaml:"server_addr"`
	Postgre   *Postgre   `yaml:"postgre"`
	Redis     *RedisRing `yaml:"redis"`
	Cache     *Cache     `yaml:"cache"`

	Debug  bool    `yaml:"debug"`
	Logger *Logger `yaml:"log"`
}

func LoadConfig

func LoadConfig() (*Config, error)

Загрузка конфигурационного файла.

func LoadConfigEnv

func LoadConfigEnv(env string) (*Config, error)

type Logger

type Logger struct {
	Format  string `yaml:"format"`
	LogFile string `yaml:"log_file"`
}

Струкура определяет формат ведения лога. Возможные значения: std - вывод лога в стандартный поток os.Stderr (значение по умолчанию), net - отправка сообщений на сервер RPC, file - запись в текстовый файл.

type Postgre

type Postgre struct {
	Enable bool   `yaml:"enable"`
	Host   string `yaml:"host"`
	Port   string `yaml:"port"`

	MaxConns uint32 `yaml:"pool_max_conns"` // int32(4)
	MinConns uint32 `yaml:"pool_min_conns"` // int32(0)

	PoolMaxConnLifetime string `yaml:"pool_max_conn_lifetime"`   // "1h"
	PoolMaxConnIdleTime string `yaml:"pool_max_conn_idle_time"`  // "30m"
	PoolHealthPeriod    string `yaml:"pool_health_check_period"` // "1m"

	Dsn string
}

func (*Postgre) Options

func (cfg *Postgre) Options(db, user, password string) error

type RedisRing

type RedisRing struct {
	Enable       bool              `yaml:"enable"`
	Addrs        map[string]string `yaml:"addrs"`
	Password     string            `yaml:"password"`
	DB           int               `yaml:"db"`
	PoolSize     int               `yaml:"pool_size"`
	MaxRetries   int               `yaml:"max_retries"`
	PoolTimeout  string            `yaml:"pool_timeout"`
	IdleTimeout  string            `yaml:"idle_timeout"`
	DialTimeout  string            `yaml:"dial_timeout"`
	ReadTimeout  string            `yaml:"read_timeout"`
	WriteTimeout string            `yaml:"write_timeout"`
}

func (*RedisRing) Options

func (cfg *RedisRing) Options() *redis.RingOptions

Jump to

Keyboard shortcuts

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