throttler

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2019 License: MIT Imports: 2 Imported by: 0

README

throttler

Throttle repeated operations in Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Throttler

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

func New

func New(maxDelay time.Duration) *Throttler

New creates a new instance of throttler. maxDelay controls what min time interval between consecutive operations is allowed at the top throttling level.

func (*Throttler) Adjust

func (t *Throttler) Adjust(done bool)

Adjust controls the throttling level depending on a result of some task execution. It throttles UP if the task is done successfully (done=true) or throttles DOWN otherwise (done=false).

func (*Throttler) Allow

func (t *Throttler) Allow() bool

Allow tries to run next operation. It returns true if the operation is actually allowed to run, otherwise the caller should wait for some time before running next operation.

func (*Throttler) Down

func (t *Throttler) Down()

Down decreases the throughput of the throttler.

func (*Throttler) Up

func (t *Throttler) Up()

Up increases the throughput of the throttler.

Jump to

Keyboard shortcuts

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