bump(github.com/benbjohnson/go-raft): d46748244f1f1830a002b8f645342426c5d73e81
This commit is contained in:
17
third_party/github.com/benbjohnson/go-raft/time.go
vendored
Normal file
17
third_party/github.com/benbjohnson/go-raft/time.go
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
package raft
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Waits for a random time between two durations and sends the current time on
|
||||
// the returned channel.
|
||||
func afterBetween(min time.Duration, max time.Duration) <-chan time.Time {
|
||||
rand := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
d, delta := min, (max - min)
|
||||
if delta > 0 {
|
||||
d += time.Duration(rand.Int63n(int64(delta)))
|
||||
}
|
||||
return time.After(d)
|
||||
}
|
Reference in New Issue
Block a user