stat.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package model
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. type ProcStat struct {
  7. Cloud2Local *CompareProcStat `json:"cloud_2_local"`
  8. Local2Cloud *CompareProcStat `json:"local_2_cloud"`
  9. }
  10. // CompareProcStat status of compare proc.
  11. type CompareProcStat struct {
  12. StartTime string `json:"start_time"`
  13. EndTime string `json:"end_time"`
  14. StepDuration JsonDuration `json:"step_duration"`
  15. LoopDuration JsonDuration `json:"loop_duration"`
  16. DelayDuration JsonDuration `json:"delay_duration"`
  17. BatchSize int `json:"batch_size"`
  18. BatchMissRetryCount int `json:"batch_miss_retry_count"`
  19. Debug bool `json:"debug"`
  20. Fix bool `json:"fix"`
  21. CurrentRangeStart JSONTime `json:"current_range_start"`
  22. CurrentRangeEnd JSONTime `json:"current_range_end"`
  23. CurrentRangeRecordsCount int `json:"current_range_records_count"`
  24. TotalRangeRecordsCount int `json:"total_range_records_count"`
  25. DiffCount int `json:"diff_count"`
  26. Sleeping bool `json:"sleeping"`
  27. SleepFrom string `json:"sleep_from,omitempty"`
  28. SleepSeconds int64 `json:"sleep_seconds,omitempty"`
  29. SleepRemainSeconds int64 `json:"sleep_remain_seconds,omitempty"`
  30. }
  31. type JSONTime time.Time
  32. func (t JSONTime) MarshalJSON() ([]byte, error) {
  33. s := fmt.Sprintf(`"%s"`, time.Time(t).Format("2006-01-02 15:04:05"))
  34. return []byte(s), nil
  35. }
  36. type JsonDuration time.Duration
  37. func (t JsonDuration) MarshalJSON() ([]byte, error) {
  38. s := fmt.Sprintf(`"%v"`, time.Duration(t))
  39. return []byte(s), nil
  40. }