go-zero/core/conf/time.go
Kevin Wan 429f85a9de
feat: slow threshold customizable in redis (#1185)
* feat: slow threshold customizable in redis

* chore: improve config robustness
2021-10-31 22:14:20 +08:00

17 lines
462 B
Go

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