UserConfToGlobal, Note that if UserConf is used, the method should be called to synchronize with GlobalConfObject because other parameters are called from this structure parameter. (注意如果使用UserConf应该调用方法同步至 GlobalConfObject 因为其他参数是调用的此结构体参数)
(config *Config)
| 7 | // because other parameters are called from this structure parameter. |
| 8 | // (注意如果使用UserConf应该调用方法同步至 GlobalConfObject 因为其他参数是调用的此结构体参数) |
| 9 | func UserConfToGlobal(config *Config) { |
| 10 | |
| 11 | // Server |
| 12 | if config.Name != "" { |
| 13 | GlobalObject.Name = config.Name |
| 14 | } |
| 15 | if config.Host != "" { |
| 16 | GlobalObject.Host = config.Host |
| 17 | } |
| 18 | if config.TCPPort != 0 { |
| 19 | GlobalObject.TCPPort = config.TCPPort |
| 20 | } |
| 21 | |
| 22 | // Zinx |
| 23 | if config.Version != "" { |
| 24 | GlobalObject.Version = config.Version |
| 25 | } |
| 26 | if config.MaxPacketSize != 0 { |
| 27 | GlobalObject.MaxPacketSize = config.MaxPacketSize |
| 28 | } |
| 29 | if config.MaxConn != 0 { |
| 30 | GlobalObject.MaxConn = config.MaxConn |
| 31 | } |
| 32 | if config.WorkerPoolSize != 0 { |
| 33 | GlobalObject.WorkerPoolSize = config.WorkerPoolSize |
| 34 | } |
| 35 | if config.MaxWorkerTaskLen != 0 { |
| 36 | GlobalObject.MaxWorkerTaskLen = config.MaxWorkerTaskLen |
| 37 | } |
| 38 | if config.WorkerMode != "" { |
| 39 | GlobalObject.WorkerMode = config.WorkerMode |
| 40 | } |
| 41 | |
| 42 | if config.MaxMsgChanLen != 0 { |
| 43 | GlobalObject.MaxMsgChanLen = config.MaxMsgChanLen |
| 44 | } |
| 45 | if config.IOReadBuffSize != 0 { |
| 46 | GlobalObject.IOReadBuffSize = config.IOReadBuffSize |
| 47 | } |
| 48 | |
| 49 | // logger |
| 50 | // By default, it is False. If the config is not initialized, the default configuration will be used. |
| 51 | // (默认是False, config没有初始化即使用默认配置) |
| 52 | GlobalObject.LogIsolationLevel = config.LogIsolationLevel |
| 53 | if GlobalObject.LogIsolationLevel > zlog.LogDebug { |
| 54 | zlog.SetLogLevel(GlobalObject.LogIsolationLevel) |
| 55 | } |
| 56 | |
| 57 | // Different from the required fields mentioned above, the logging module should use the default configuration if it is not configured. |
| 58 | // (不同于上方必填项 日志目前如果没配置应该使用默认配置) |
| 59 | if config.LogDir != "" { |
| 60 | GlobalObject.LogDir = config.LogDir |
| 61 | } |
| 62 | |
| 63 | if config.LogFile != "" { |
| 64 | GlobalObject.LogFile = config.LogFile |
| 65 | zlog.SetLogFile(GlobalObject.LogDir, GlobalObject.LogFile) |
| 66 | } |
no test coverage detected