insertstrategy

package
v0.0.0-...-aec62d2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SleepRegulator

type SleepRegulator interface {
	// for a worker, if required, the goroutine will sleep for the
	// required amount of time
	Sleep(workerNum int, startedWorkAt time.Time)
}

SleepRegulator keeps the time required for each load worker to sleep between batch inserts. When calling the Sleep method for a worker, if required, the goroutine will sleep for the required amount of time

func NewSleepRegulator

func NewSleepRegulator(insertIntervalString string, numWorkers int, initialRand *rand.Rand) (SleepRegulator, error)

NewSleepRegulator returns an implementation of the SleepRegulator interface, the insertIntervalString is parsed for a given number of workers (numWorkers). InsertIntervals are defined as minimum time between the start of two consecutive inserts. Time may be expressed as constant or range. It goes like this: numWorkers=2, string='0,1' => worker '0' insert ASAP, worker '1' at least 1 second between inserts numWorkers=2, string='2'=> worker '0' and all workers after it have at least 2 seconds between inserts numWorkers=3, string='1,2' => worker '0' at least 1 second, workers '1' and '2' at least 2 seconds between inserts numWorkers=1, string='0-1' => worker '0' needs to have [0,1) seconds between inserts numWorkers=3, string='1,2-4'=> worker '0' have 1 second between inserts, workers '1' and '2' have [2,4) seconds between inserts

func NoWait

func NoWait() SleepRegulator

NoWait returns a sleep regulator that doesn't make any worker sleep, at all.

Jump to

Keyboard shortcuts

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