insertstrategy

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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