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

Method ReportToServer

tars/propertyf.go:346–442  ·  view source on GitHub ↗

ReportToServer report to the remote propertyreport server.

()

Source from the content-addressed store, hash-verified

344
345// ReportToServer report to the remote propertyreport server.
346func (p *PropertyReportHelper) ReportToServer() {
347 statMsg := make(map[propertyf.StatPropMsgHead]propertyf.StatPropMsgBody)
348
349 var head propertyf.StatPropMsgHead
350 head.IPropertyVer = 2
351 head.ModuleName = GetClientConfig().ModuleName
352 head.Ip = tools.GetLocalIP()
353 if cfg := GetServerConfig(); cfg != nil {
354 head.Ip = cfg.LocalIP
355 if cfg.Enableset {
356 setList := strings.Split(cfg.Setdivision, ".")
357 head.ModuleName = cfg.App + "." + cfg.Server + "." + setList[0] + setList[1] + setList[2]
358 head.SetName = setList[0]
359 head.SetArea = setList[1]
360 head.SetID = setList[2]
361 }
362 }
363 // head.SContainer = cfg.Container
364
365 p.reportPtrs.Range(func(key, val interface{}) bool {
366 v := val.(*PropertyReport)
367 head.PropertyName = v.key
368
369 var body propertyf.StatPropMsgBody
370 body.VInfo = make([]propertyf.StatPropInfo, 0)
371 for _, m := range v.reportMethods {
372 if nil == m {
373 continue
374 }
375
376 var info propertyf.StatPropInfo
377 bflag := false
378 desc := m.Enum().String()
379 result := m.Get()
380
381 // todo: use interface method IsDefault() bool
382 switch desc {
383 case "Sum":
384 if result != "0" {
385 bflag = true
386 }
387 case "Avg":
388 if result != "0" {
389 bflag = true
390 }
391 case "Distr":
392 if result != "" {
393 bflag = true
394 }
395 case "Max":
396 if result != "-9999999" {
397 bflag = true
398 }
399 case "Min":
400 if result != "0" {
401 bflag = true
402 }
403 case "Count":

Callers 1

RunMethod · 0.95

Calls 9

GetLocalIPFunction · 0.92
GetClientConfigFunction · 0.85
GetServerConfigFunction · 0.85
EnumMethod · 0.65
GetMethod · 0.65
ReportPropMsgMethod · 0.65
ContextMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected