stat.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package service
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/job/main/passport-game-data/model"
  6. )
  7. // CompareProcStat get actual compare proc stat.
  8. func (s *Service) CompareProcStat(c context.Context) *model.ProcStat {
  9. var c2lStat *model.CompareProcStat
  10. if s.c.Compare.Cloud2Local.On {
  11. cc := s.c2lC
  12. c2lStat = &model.CompareProcStat{
  13. StartTime: s.c.Compare.Cloud2Local.StartTime,
  14. EndTime: s.c.Compare.Cloud2Local.EndTime,
  15. StepDuration: model.JsonDuration(cc.StepDuration),
  16. LoopDuration: model.JsonDuration(cc.LoopDuration),
  17. DelayDuration: model.JsonDuration(cc.DelayDuration),
  18. BatchSize: cc.BatchSize,
  19. BatchMissRetryCount: cc.BatchMissRetryCount,
  20. Debug: cc.Debug,
  21. Fix: cc.Fix,
  22. CurrentRangeStart: model.JSONTime(cc.st),
  23. CurrentRangeEnd: model.JSONTime(cc.ed),
  24. CurrentRangeRecordsCount: cc.rangeCount,
  25. TotalRangeRecordsCount: cc.totalCount,
  26. DiffCount: cc.diffCount,
  27. Sleeping: cc.sleeping,
  28. }
  29. if cc.sleeping {
  30. c2lStat.SleepSeconds = cc.sleepingSeconds
  31. c2lStat.SleepFrom = time.Unix(cc.sleepFromTs, 0).Format(_timeFormat)
  32. c2lStat.SleepRemainSeconds = cc.sleepingSeconds - (time.Now().Unix() - cc.sleepFromTs)
  33. }
  34. }
  35. var l2cStat *model.CompareProcStat
  36. if s.c.Compare.Local2Cloud.On {
  37. cc := s.l2cC
  38. l2cStat = &model.CompareProcStat{
  39. StartTime: s.c.Compare.Local2Cloud.StartTime,
  40. EndTime: s.c.Compare.Local2Cloud.EndTime,
  41. StepDuration: model.JsonDuration(cc.StepDuration),
  42. LoopDuration: model.JsonDuration(cc.LoopDuration),
  43. DelayDuration: model.JsonDuration(cc.DelayDuration),
  44. BatchSize: cc.BatchSize,
  45. BatchMissRetryCount: cc.BatchMissRetryCount,
  46. Debug: cc.Debug,
  47. Fix: cc.Fix,
  48. CurrentRangeStart: model.JSONTime(cc.st),
  49. CurrentRangeEnd: model.JSONTime(cc.ed),
  50. CurrentRangeRecordsCount: cc.rangeCount,
  51. TotalRangeRecordsCount: cc.totalCount,
  52. DiffCount: cc.diffCount,
  53. Sleeping: cc.sleeping,
  54. }
  55. if cc.sleeping {
  56. l2cStat.SleepSeconds = cc.sleepingSeconds
  57. l2cStat.SleepFrom = time.Unix(cc.sleepFromTs, 0).Format(_timeFormat)
  58. l2cStat.SleepRemainSeconds = cc.sleepingSeconds - (time.Now().Unix() - cc.sleepFromTs)
  59. }
  60. }
  61. return &model.ProcStat{
  62. Cloud2Local: c2lStat,
  63. Local2Cloud: l2cStat,
  64. }
  65. }