Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { App *App `json:"app" toml:"app"` // [mysql] MySQL *MySQL `json:"mysql" toml:"mysql"` // MongoDB *mongodb `json:"mongo" toml:"mongo"` // [http] Http *Http `json:"http" toml:"http"` // [grpc] Grpc *Grpc `json:"grpc" toml:"grpc"` // 程序接入Jaeger配置 Jaeger *jaeger `toml:"jaeger"` }
程序的配置对象 config --> object
func DefaultConfig ¶
func DefaultConfig() *Config
func LoadConfigFromEnv ¶
通过环境变量读取配置 采用第三方库: "github.com/caarlos0/env/v6" 读取环境变量 环境变量 ---> config object
func LoadConfigFromToml ¶
toml 文件加载 使用到的第三方库: "github.com/BurntSushi/toml"
type Grpc ¶
type Grpc struct { Host string `json:"host" toml:"host" env:"MCENTER_GRPC_HOST"` Port int `json:"port" toml:"port" env:"MCENTER_GRPC_PORT"` }
func NewDefaultGrpc ¶
func NewDefaultGrpc() *Grpc
type Http ¶
type MySQL ¶
type MySQL struct { Host string `json:"host" toml:"host" env:"MYSQL_HOST"` Port int `json:"port" toml:"port" env:"MYSQL_PORT"` DB string `json:"db" toml:"db" env:"MYSQL_DB"` Username string `json:"username" toml:"username" env:"MYSQL_USERNAME"` Password string `json:"password" toml:"password" env:"MYSQL_PASSWORD"` // 高级参数 MaxOpenConn int `toml:"max_open_conn" env:"MYSQL_MAX_OPEN_CONN"` MaxIdleConn int `toml:"max_idle_conn" env:"MYSQL_MAX_IDLE_CONN"` MaxLifeTime int `toml:"max_life_time" env:"MYSQL_MAX_LIFE_TIME"` MaxIdleTime int `toml:"max_idle_time" env:"MYSQL_MAX_IDLE_TIME"` // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.