setting

package
v0.0.0-...-e972461 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(cfg *Configuration) error

Types

type AppSettingS

type AppSettingS struct {
	DefaultPageSize       int           `mapstructure:"DefaultPageSize"`
	MaxPageSize           int           `mapstructure:"MaxPageSize"`
	ServerShutdownTimeout time.Duration `mapstructure:"ServerShutdownTimeout"`
}

type Configuration

type Configuration struct {
	Server    ServerSettingS    `mapstructure:"Server"`
	App       AppSettingS       `mapstructure:"App"`
	Log       LogSettingS       `mapstructure:"Log"`
	Database  DatabaseSettingS  `mapstructure:"Database"`
	Ratelimit RatelimitSettingS `mapstructure:"Ratelimit"`
}

UnmarshalKey / Sub only uses read config, neglects environment variables https://github.com/spf13/viper/issues/1012

type DatabaseSettingS

type DatabaseSettingS struct {
	DBType       string `mapstructure:"DBType"`
	UserName     string `mapstructure:"UserName"`
	Password     string `mapstructure:"Password"`
	Host         string `mapstructure:"Host"`
	DBName       string `mapstructure:"DBName"`
	Charset      string `mapstructure:"Charset"`
	ParseTime    bool   `mapstructure:"ParseTime"`
	MaxIdleConns int    `mapstructure:"MaxIdleConns"`
	MaxOpenConns int    `mapstructure:"MaxOpenConns"`
	MigrationURL string `mapstructure:"MigrationURL"`
}

type LogSettingS

type LogSettingS struct {
	LogSavePath string `mapstructure:"LogSavePath"`
	LogFileName string `mapstructure:"LogFileName"`
	MaxSize     int    `mapstructure:"MaxSize"`
	MaxBackups  int    `mapstructure:"MaxBackups"`
	Compress    bool   `mapstructure:"Compress"`
	Level       string `mapstructure:"Level"`
}

type RatelimitSettingS

type RatelimitSettingS struct {
	Enable          bool    `mapstructure:"Enable"`
	ConfigFile      string  `mapstructure:"ConfigFile"`
	CPULoadThresh   float64 `mapstructure:"CPULoadThresh"`
	CPULoadStrategy int     `mapstructure:"CPULoadStrategy"`
}

type ServerSettingS

type ServerSettingS struct {
	RunMode      string        `mapstructure:"RunMode"`
	HTTPPort     string        `mapstructure:"HTTPPort"`
	ReadTimeout  time.Duration `mapstructure:"ReadTimeout"`
	WriteTimeout time.Duration `mapstructure:"WriteTimeout"`
}

Jump to

Keyboard shortcuts

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