MCPcopy
hub / github.com/TarsCloud/TarsGo / parseServerConfig

Method parseServerConfig

tars/application.go:168–290  ·  view source on GitHub ↗
(c *conf.Conf)

Source from the content-addressed store, hash-verified

166}
167
168func (a *application) parseServerConfig(c *conf.Conf) {
169 // init server config
170 if strings.EqualFold(c.GetString("/tars/application<enableset>"), "Y") {
171 a.svrCfg.Enableset = true
172 a.svrCfg.Setdivision = c.GetString("/tars/application<setdivision>")
173 }
174 sMap := c.GetMap("/tars/application/server")
175 a.svrCfg.Node = sMap["node"]
176 a.svrCfg.App = sMap["app"]
177 a.svrCfg.Server = sMap["server"]
178 a.svrCfg.LocalIP = c.GetStringWithDef("/tars/application/server<localip>", a.svrCfg.LocalIP)
179 a.svrCfg.NodeName = c.GetStringWithDef("/tars/application/server<node_name>", a.svrCfg.LocalIP)
180 a.svrCfg.Local = c.GetString("/tars/application/server<local>")
181 // svrCfg.Container = c.GetString("/tars/application<container>")
182
183 // init log
184 a.svrCfg.LogPath = sMap["logpath"]
185 a.svrCfg.LogSize = tools.ParseLogSizeMb(sMap["logsize"])
186 a.svrCfg.LogNum = tools.ParseLogNum(sMap["lognum"])
187 a.svrCfg.LogLevel = sMap["logLevel"]
188 a.svrCfg.Config = sMap["config"]
189 a.svrCfg.Notify = sMap["notify"]
190 a.svrCfg.BasePath = sMap["basepath"]
191 a.svrCfg.DataPath = sMap["datapath"]
192 a.svrCfg.Log = sMap["log"]
193
194 // add version info
195 a.svrCfg.Version = Version
196 // add adapters config
197 a.svrCfg.Adapters = make(map[string]adapterConfig)
198
199 // add timeout config
200 a.svrCfg.AcceptTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<accepttimeout>", AcceptTimeout))
201 a.svrCfg.ReadTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<readtimeout>", ReadTimeout))
202 a.svrCfg.WriteTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<writetimeout>", WriteTimeout))
203 a.svrCfg.HandleTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<handletimeout>", HandleTimeout))
204 a.svrCfg.IdleTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<idletimeout>", IdleTimeout))
205 a.svrCfg.ZombieTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<zombietimeout>", ZombieTimeout))
206 a.svrCfg.QueueCap = c.GetIntWithDef("/tars/application/server<queuecap>", QueueCap)
207 a.svrCfg.GracedownTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<gracedowntimeout>", GracedownTimeout))
208
209 // add tcp config
210 a.svrCfg.TCPReadBuffer = c.GetIntWithDef("/tars/application/server<tcpreadbuffer>", TCPReadBuffer)
211 a.svrCfg.TCPWriteBuffer = c.GetIntWithDef("/tars/application/server<tcpwritebuffer>", TCPWriteBuffer)
212 a.svrCfg.TCPNoDelay = c.GetBoolWithDef("/tars/application/server<tcpnodelay>", TCPNoDelay)
213 // add routine number
214 a.svrCfg.MaxInvoke = c.GetInt32WithDef("/tars/application/server<maxroutine>", MaxInvoke)
215 // add adapter & report config
216 a.svrCfg.PropertyReportInterval = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<propertyreportinterval>", PropertyReportInterval))
217 a.svrCfg.StatReportInterval = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<statreportinterval>", StatReportInterval))
218 a.svrCfg.MainLoopTicker = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/server<mainloopticker>", MainLoopTicker))
219 a.svrCfg.StatReportChannelBufLen = c.GetInt32WithDef("/tars/application/server<statreportchannelbuflen>", StatReportChannelBufLen)
220 // maxPackageLength
221 a.svrCfg.MaxPackageLength = c.GetIntWithDef("/tars/application/server<maxPackageLength>", MaxPackageLength)
222
223 // tls
224 a.svrCfg.Key = c.GetString("/tars/application/server<key>")
225 a.svrCfg.Cert = c.GetString("/tars/application/server<cert>")

Callers 1

initConfigMethod · 0.95

Calls 15

ParseLogSizeMbFunction · 0.92
ParseLogNumFunction · 0.92
ParseTimeOutFunction · 0.92
NewServerTlsConfigFunction · 0.92
ParseFunction · 0.92
WithQueueCapFunction · 0.85
WithTlsConfigFunction · 0.85
newTarsServerConfFunction · 0.85
WithMaxInvokeFunction · 0.85
RegisterAdminFunction · 0.85
GetStringMethod · 0.80
GetMapMethod · 0.80

Tested by

no test coverage detected