limiter

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 3 Imported by: 0

README

concurrency-limiter

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

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

limit: max number of concurrent goroutines that can access aresource count: current number of goroutines accessing a resource waitList: list of goroutines waiting to access a resource. Goroutines will be added to this list if the number of concurrent requests are greater than the limit specified timeout: If this field is specified , goroutines will be automatically removed from the waitlist after the time passes the timeout specified even if the number of concurrent requests is greater than the limit.

func New added in v0.4.2

func New(limit int) *Limiter

func (*Limiter) Finish

func (l *Limiter) Finish()

Finish will remove the goroutine from the waiting list and sends a signal to the waiting goroutine to access the resource

func (*Limiter) Wait

func (l *Limiter) Wait()

Wait method waits if the number of concurrent requests is more than the limit specified. If a timeout is configured , then the goroutine will wait until the timeout occurs and then proceeds to access the resource irrespective of whether it has received a signal in the done channel.

func (*Limiter) WithTimeout

func (l *Limiter) WithTimeout(timeout int) *Limiter

timeout: If this field is specified , goroutines will be automatically removed from the waitlist after the time passes the timeout specified even if the number of concurrent requests is greater than the limit.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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