Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithTimeout ¶ added in v0.5.0
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.
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. (in ms)
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.