jitter

package
v1.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Jitterer

type Jitterer struct {
	// contains filtered or unexported fields
}

func New

func New(seedString string) Jitterer

New uses a string to calculate a deterministic seed for an random number generator.

The actual implementation does not really matter, we just need to condense a string into an 64-bit number. Also: cryptocraphic security is not important here, we just don't want all cron jobs to run at the same time.

func (Jitterer) Jitter

func (j Jitterer) Jitter(cron event.Cron) event.Cron

Jitter takes a Cron event and adds random values for any properties not set.

The values are chosen uniformly-distributed within the validity area of the property. E.g. Minutes will be set to a value between 0 and 59. The exception is the DayOfMonth property. It will never use a value above 28, to ensure it also runs in short months.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL