time.go 462 B

12345678910111213141516
  1. package conf
  2. import "time"
  3. const minDuration = 100 * time.Microsecond
  4. // CheckedDuration returns the duration that guaranteed to be greater than 100us.
  5. // Why we need this is because users sometimes intend to use 500 to represent 500ms.
  6. // In config, duration less than 100us should always be missing ms etc.
  7. func CheckedDuration(duration time.Duration) time.Duration {
  8. if duration > minDuration {
  9. return duration
  10. }
  11. return duration * time.Millisecond
  12. }