1
0

client_global_traffic.go 1.1 KB

1234567891011121314151617181920
  1. package model
  2. // ClientGlobalTraffic mirrors a master panel's aggregated (global) usage for a
  3. // client hosted on this panel. Masters push one row per (master, email) so the
  4. // node can display the client's true cross-panel total and enforce its quota
  5. // locally. The values never feed back into client_traffics — that table keeps
  6. // this panel's local-only counters, which is what keeps every master's
  7. // delta-baseline accounting over our snapshot correct.
  8. //
  9. // Rows are overwritten in place on every push (not max-merged), so a traffic
  10. // reset on the master propagates here within one push cycle. Readers that need
  11. // a single number fold the per-master rows with MAX.
  12. type ClientGlobalTraffic struct {
  13. Id int `json:"id" gorm:"primaryKey;autoIncrement"`
  14. MasterGuid string `json:"masterGuid" gorm:"uniqueIndex:idx_master_email,priority:1;not null"`
  15. Email string `json:"email" gorm:"uniqueIndex:idx_master_email,priority:2;not null"`
  16. Up int64 `json:"up"`
  17. Down int64 `json:"down"`
  18. UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime:milli"`
  19. }