From 635f849d70ae31df42dab56dacf62727a313db28 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期六, 06 七月 2024 20:17:04 +0800 Subject: [PATCH] 修改比对为并发 --- config/config.go | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index 5952d22..b71dc57 100644 --- a/config/config.go +++ b/config/config.go @@ -8,18 +8,19 @@ "github.com/spf13/viper" ) -type database struct { +type mainConfig struct { + ServePort int `mapstructure:"servePort"` + WorkerNum int `mapstructure:"workerNum"` MysqlAddr string `mapstructure:"mysqlAddr"` Username string `mapstructure:"username"` Password string `mapstructure:"password"` Database string `mapstructure:"database"` PersonTable string `mapstructure:"personTable"` - ServePort int `mapstructure:"servePort"` } -var DbPersonCompInfo = &database{} +var MainConf = &mainConfig{} -type LogConfig struct { +type logConfig struct { Path string `mapstructure:"path"` //鏃ュ織瀛樺偍璺緞 Level int `mapstructure:"level"` //鏃ュ織绛夌骇 MaxSize int `mapstructure:"maxSize"` //鏃ュ織鏂囦欢澶у皬涓婇檺 @@ -27,7 +28,7 @@ MaxAge int `mapstructure:"maxAge"` //淇濈暀鍘嬬缉鍖呭ぉ鏁� } -var LogConf = &LogConfig{} +var LogConf = &logConfig{} func Init() error { var err error @@ -53,8 +54,12 @@ } func read2Conf(v *viper.Viper) { - v.UnmarshalKey("database", DbPersonCompInfo) + v.UnmarshalKey("main", MainConf) v.UnmarshalKey("log", LogConf) logger.SetLevel(LogConf.Level) + + if MainConf.WorkerNum == 0 { + MainConf.WorkerNum = 30 + } } -- Gitblit v1.8.0