INNER CODE UNIT · Go
mtbf
asobti/kube-monkey · internal/pkg/calendar/calendar.go:86
mtbf := time.Duration(amount) * unit
if mtbf/unit != time.Duration(amount) {
return 0, fmt.Errorf("invalid mtbf %q: too large", value)
}
return mtbf, nil
}
// KillTimesInRange returns the times at which a victim with the given mtbf
// should be killed today, at random within the range specified by startHour and
// endHour. A victim dies 24h/mtbf times a day on average, so an mtbf shorter
// than a day gives several kills and a longer one gives a kill only on some
// days. When part of the range has already passed, only the share of the kills
// belonging to the remaining part is scheduled.
func KillTimesInRange(mtbf time.Duration, startHour int, endHour int, loc *time.Location) []time.Time {
return killTimesInRange(time.Now(), newRand(), mtbf, startHour, endHour, loc)
}