INNER CODE UNIT · Go

KillTimesInRange

asobti/kube-monkey · internal/pkg/calendar/calendar.go:100

func KillTimesInRange(mtbf time.Duration, startHour int, endHour int, loc *time.Location) []time.Time {
	return killTimesInRange(time.Now(), newRand(), mtbf, startHour, endHour, loc)
}

// RandomTimeInRange returns a single random time within the range specified by
// startHour and endHour. It reports false when the range has already passed.
func RandomTimeInRange(startHour int, endHour int, loc *time.Location) (time.Time, bool) {
	return randomTimeInRange(time.Now(), newRand(), startHour, endHour, loc)
}

func killTimesInRange(now time.Time, r *rand.Rand, mtbf time.Duration, startHour int, endHour int, loc *time.Location) []time.Time {
	start, remaining, full := rangeToday(now, startHour, endHour, loc)
	if remaining == 0 || mtbf <= 0 {
		return nil
	}

	// Kills are spread over the day but only ever happen inside the range, so
	// the share of the range still ahead of us is the share of the day's kills

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…