Documentation
¶
Overview ¶
lib/config/fx.go
Index ¶
Constants ¶
Variables ¶
View Source
var Module = fx.Module("config", fx.Provide(LoadConfigFromYAML))
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { MySQL MySQLConfig `yaml:"mysql"` Redis RedisConfig `yaml:"redis"` Task TaskConfig `yaml:"task"` Logger LoggerConfig `yaml:"logger"` Server ServerConfig `yaml:"server"` }
Config 结构体,包含 MySQL 和 Redis 配置
func LoadConfigFromYAML ¶
func LoadConfigFromYAML(filepath ConfigFile) (*Config, error)
读取 YAML 配置文件
type ConfigFile ¶
type ConfigFile string
type LoggerConfig ¶
type LoggerConfig struct { Filename string `yaml:"filename"` ErrFileName string `yaml:"err_filename"` AccessFileName string `yaml:"access_filename"` LogLevel string `yaml:"log_level"` }
TaskConfig 结构体,包含 Task配置
type MySQLConfig ¶
type MySQLConfig struct { Host string `yaml:"host"` Port int `yaml:"port"` Username string `yaml:"username"` Password string `yaml:"password"` DBName string `yaml:"dbname"` Charset string `yaml:"charset"` ConnectTimeout time.Duration `yaml:"connect_timeout"` ReadTimeout time.Duration `yaml:"read_timeout"` WriteTimeout time.Duration `yaml:"write_timeout"` }
MySQLConfig 结构体,包含 MySQL 配置项和超时设置
type RedisConfig ¶
type RedisConfig struct { Host string `yaml:"host"` Port int `yaml:"port"` Password string `yaml:"password"` DB int `yaml:"db"` ConnectTimeout time.Duration `yaml:"connect_timeout"` ReadTimeout time.Duration `yaml:"read_timeout"` WriteTimeout time.Duration `yaml:"write_timeout"` }
RedisConfig 结构体,包含 Redis 配置项和超时设置
type ServerConfig ¶
type ServerConfig struct {
ListenAddr string `yaml:"listen_addr"`
}
type TaskConfig ¶
type TaskConfig struct {
ThreadNum int `yaml:"thread_num"`
}
TaskConfig 结构体,包含 Task配置
Click to show internal directories.
Click to hide internal directories.