throttling

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2017 License: BSD-3-Clause Imports: 2 Imported by: 1

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 NewThrottler

func NewThrottler(perSecond uint) *Throttler

Returns a new Throttler, which allows the retrival of up to perSecond tickets per second.

After a waiting for a ticket the ticket has either to be returned or used

func (*Throttler) RequestTicket

func (throttler *Throttler) RequestTicket()

Blocks until a ticket is available. Afterwards either ReturnUnusedTicket() or UseTicket has to be called.

func (*Throttler) ReturnUnusedTicket

func (throttler *Throttler) ReturnUnusedTicket()

func (*Throttler) TearDown

func (throttler *Throttler) TearDown()

Tears down the throttler. It is the callers responsibility that no thread is in RequestTicket(). Whether the threads in RequestTicket() are woken up or not is completely undefined.

func (*Throttler) UseTicket

func (throttler *Throttler) UseTicket()

This function has to be called when actually using a requested ticket, otherwise no new ticket will be generated.

Jump to

Keyboard shortcuts

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