Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
func jitterSleep(sleep int, beaconType string) {
min := int(float64(sleep) * .90)
max := int(float64(sleep) * 1.10)
randomSleep := rand.Intn(max - min + 1) + min
log.Printf("[%s] Next beacon going out in %d seconds", beaconType, randomSleep)
time.Sleep(time.Duration(randomSleep) * time.Second)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment