package_stats.go 537 B

12345678910111213141516171819202122232425
  1. package server
  2. import (
  3. "time"
  4. )
  5. // packageStats represent the stats we need for a package.
  6. // It has sending time and the size of the package.
  7. type packageStats struct {
  8. sendingTime time.Time
  9. size int
  10. }
  11. // NewPackageStats creates a pacakgeStats and return the pointer to it.
  12. func NewPackageStats(now time.Time, size int) *packageStats {
  13. return &packageStats{
  14. sendingTime: now,
  15. size: size,
  16. }
  17. }
  18. // Time return the sending time of the package.
  19. func (ps *packageStats) Time() time.Time {
  20. return ps.sendingTime
  21. }