(c *conf.Conf)
| 290 | } |
| 291 | |
| 292 | func (a *application) parseClientConfig(c *conf.Conf) { |
| 293 | // init client config |
| 294 | cMap := c.GetMap("/tars/application/client") |
| 295 | a.cltCfg.Locator = cMap["locator"] |
| 296 | a.cltCfg.Stat = cMap["stat"] |
| 297 | a.cltCfg.Property = cMap["property"] |
| 298 | a.cltCfg.ModuleName = cMap["modulename"] |
| 299 | a.cltCfg.AsyncInvokeTimeout = c.GetIntWithDef("/tars/application/client<async-invoke-timeout>", AsyncInvokeTimeout) |
| 300 | a.cltCfg.RefreshEndpointInterval = c.GetIntWithDef("/tars/application/client<refresh-endpoint-interval>", refreshEndpointInterval) |
| 301 | a.cltCfg.ReportInterval = c.GetIntWithDef("/tars/application/client<report-interval>", reportInterval) |
| 302 | a.cltCfg.CheckStatusInterval = c.GetIntWithDef("/tars/application/client<check-status-interval>", checkStatusInterval) |
| 303 | a.cltCfg.KeepAliveInterval = c.GetIntWithDef("/tars/application/client<keep-alive-interval>", keepAliveInterval) |
| 304 | |
| 305 | // add client timeout |
| 306 | a.cltCfg.ClientQueueLen = c.GetIntWithDef("/tars/application/client<clientqueuelen>", ClientQueueLen) |
| 307 | a.cltCfg.ClientIdleTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/client<clientidletimeout>", ClientIdleTimeout)) |
| 308 | a.cltCfg.ClientReadTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/client<clientreadtimeout>", ClientReadTimeout)) |
| 309 | a.cltCfg.ClientWriteTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/client<clientwritetimeout>", ClientWriteTimeout)) |
| 310 | a.cltCfg.ClientDialTimeout = tools.ParseTimeOut(c.GetIntWithDef("/tars/application/client<clientdialtimeout>", ClientDialTimeout)) |
| 311 | a.cltCfg.ReqDefaultTimeout = c.GetInt32WithDef("/tars/application/client<reqdefaulttimeout>", ReqDefaultTimeout) |
| 312 | a.cltCfg.ObjQueueMax = c.GetInt32WithDef("/tars/application/client<objqueuemax>", ObjQueueMax) |
| 313 | a.cltCfg.context["node_name"] = a.svrCfg.NodeName |
| 314 | ca := c.GetString("/tars/application/client<ca>") |
| 315 | if ca != "" { |
| 316 | cert := c.GetString("/tars/application/client<cert>") |
| 317 | key := c.GetString("/tars/application/client<key>") |
| 318 | ciphers := c.GetString("/tars/application/client<ciphers>") |
| 319 | clientTlsConfig, err := ssl.NewClientTlsConfig(ca, cert, key, ciphers) |
| 320 | if err != nil { |
| 321 | panic(err) |
| 322 | } |
| 323 | a.clientTlsConfig = clientTlsConfig |
| 324 | } |
| 325 | |
| 326 | auths := c.GetDomain("/tars/application/client") |
| 327 | for _, objName := range auths { |
| 328 | authInfo := make(map[string]string) |
| 329 | // authInfo["accesskey"] = c.GetString("/tars/application/client/" + objName + "<accesskey>") |
| 330 | // authInfo["secretkey"] = c.GetString("/tars/application/client/" + objName + "<secretkey>") |
| 331 | authInfo["ca"] = c.GetString("/tars/application/client/" + objName + "<ca>") |
| 332 | authInfo["cert"] = c.GetString("/tars/application/client/" + objName + "<cert>") |
| 333 | authInfo["key"] = c.GetString("/tars/application/client/" + objName + "<key>") |
| 334 | authInfo["ciphers"] = c.GetString("/tars/application/client/" + objName + "<ciphers>") |
| 335 | a.clientObjInfo[objName] = authInfo |
| 336 | if authInfo["ca"] != "" { |
| 337 | objTlsConfig, err := ssl.NewClientTlsConfig(authInfo["ca"], authInfo["cert"], authInfo["key"], authInfo["ciphers"]) |
| 338 | if err != nil { |
| 339 | panic(err) |
| 340 | } |
| 341 | a.clientObjTlsConfig[objName] = objTlsConfig |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | // Run the application |
| 347 | func (a *application) Run(opts ...Option) { |
no test coverage detected