config

package
v0.0.0-...-677e9b2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 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"` // "10m"
	CleanTimeout string `yaml:"cleanup"`    // "15m"
	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"`
	Loger *Loger `yaml:"log"`
}

func LoadConfig

func LoadConfig() (*Config, error)

func LoadConfigEnv

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

type Loger

type Loger struct {
	Format  string `yaml:"format"`
	LogFile string `yaml:"log_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 {
	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