micro/util/jitter/random.go
Vasiliy Tolstov 5eb0e56373 move all imports to own domain
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-02 19:55:07 +03:00

16 lines
370 B
Go

// Package jitter provides a random jitter
package jitter // import "go.unistack.org/micro/v3/util/jitter"
import (
"time"
"go.unistack.org/micro/v3/util/rand"
)
// Random returns a random time to jitter with max cap specified
func Random(d time.Duration) time.Duration {
var rng rand.Rand
v := rng.Float64() * float64(d.Nanoseconds())
return time.Duration(v)
}