config

package
v0.0.0-...-01003e4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 6 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 {
	Mysql    MysqlConfig
	HTTP     HTTPConfig
	Redis    RedisConfig
	Logger   LoggerConfig
	Server   ServerConfig
	CacheTTL time.Duration `mapstructure:"ttl"`
}

func Init

func Init(configsDir string) (*Config, error)

Init populates Config struct with values from config file located at filepath and environment variables.

type HTTPConfig

type HTTPConfig struct {
	Host               string        `mapstructure:"host"`
	Port               string        `mapstructure:"port"`
	ReadTimeout        time.Duration `mapstructure:"readTimeout"`
	WriteTimeout       time.Duration `mapstructure:"writeTimeout"`
	MaxHeaderMegabytes int           `mapstructure:"maxHeaderBytes"`
}

type LogType

type LogType int32
const (
	Zap    LogType = 0
	Logrus LogType = 1
)

type LoggerConfig

type LoggerConfig struct {
	Development       bool    `yaml:"development" mapstructure:"development"`
	DisableCaller     bool    `yaml:"disableCaller" mapstructure:"disableCaller"`
	DisableStacktrace bool    `yaml:"disableStacktrace" mapstructure:"disableStacktrace"`
	Encoding          string  `yaml:"encoding" mapstructure:"encoding"`
	LogLevel          string  `yaml:"level" mapstructure:"level"`
	LogType           LogType `yaml:"logType" mapstructure:"logType"`
}

type MysqlConfig

type MysqlConfig struct {
	Username  string            `yaml:"username" mapstructure:"username"`
	Password  string            `yaml:"password" mapstructure:"password"`
	Protocol  string            `yaml:"protocol" mapstructure:"protocol"`
	Address   string            `yaml:"address" mapstructure:"address"`
	Database  string            `yaml:"database" mapstructure:"database"`
	Params    map[string]string `yaml:"params" mapstructure:"params"`
	Collation string            `yaml:"collation" mapstructure:"collation"`
	Loc       *time.Location    `yaml:"location" mapstructure:"loc"`
	TLSConfig string            `yaml:"tlsConfig" mapstructure:"tlsConfig"`

	Timeout      time.Duration `yaml:"timeout" mapstructure:"timeout"`
	ReadTimeout  time.Duration `yaml:"readTimeout" mapstructure:"readTimeout"`
	WriteTimeout time.Duration `yaml:"writeTimeout" mapstructure:"writeTimeout"`

	AllowAllFiles           bool   `yaml:"allowAllFiles" mapstructure:"allowAllFiles"`
	AllowCleartextPasswords bool   `yaml:"allowCleartextPasswords" mapstructure:"allowCleartextPasswords"`
	AllowOldPasswords       bool   `yaml:"allowOldPasswords" mapstructure:"allowOldPasswords"`
	ClientFoundRows         bool   `yaml:"clientFoundRows" mapstructure:"clientFoundRows"`
	ColumnsWithAlias        bool   `yaml:"columnsWithAlias" mapstructure:"columnsWithAlias"`
	InterpolateParams       bool   `yaml:"interpolateParams" mapstructure:"interpolateParams"`
	MultiStatements         bool   `yaml:"multiStatements" mapstructure:"multiStatements"`
	ParseTime               bool   `yaml:"parseTime" mapstructure:"parseTime"`
	GoogleAuthFile          string `yaml:"googleAuthFile" mapstructure:"googleAuthFile"`
}

MysqlConfig is settings of a MySQL server. It contains almost same fields as mysql.Config, but with some different field names and tags.

func (*MysqlConfig) FormatDSN

func (m *MysqlConfig) FormatDSN() string

FormatDSN returns MySQL DSN from settings.

type RedisConfig

type RedisConfig struct {
	Addr         string `mapstructure:"addr"`
	Password     string `mapstructure:"password"`
	DB           int    `mapstructure:"db"`
	PoolSize     int    `mapstructure:"poolSize"`
	MinIdleConns int    `mapstructure:"minIdleConns"`
	PoolTimeout  int    `mapstructure:"poolTimeout"`
}

type ServerConfig

type ServerConfig struct {
	AppVersion string `yaml:"appVersion" mapstructure:"appVersion"`
	Mode       string `yaml:"mode" mapstructure:"mode"`
	Debug      bool   `yaml:"debug" mapstructure:"debug"`
}

Jump to

Keyboard shortcuts

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