limit

package
v1.4.8-RC1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2017 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package limit provides primitives to limit concurrency.

Note that this is not to be confused with rate-limiting. With concurrency limiting (which is what this package does), you are limiting the number of operations that can be running at any given point in time. With rate limiting, you are limiting the number of operations that can be fired within a given time window.

For instance, even if you limit concurrency to 1, you can still have N requests per second where N is an arbitrarily large number, given that each request takes 1/N second to complete.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrencyLimiter

type ConcurrencyLimiter interface {
	// Acquire acquires the right to proceed.  It blocks if the concurrency
	// limit has been reached.
	Acquire()
	// Release signals that an operation has completed.
	Release()
	// Wait blocks until all operations that have called Acquire thus far
	// are completed.
	Wait()
}

ConcurrencyLimiter limits the number of concurrent operations If the ConcurrencyLimiter is initialized with a concurrency of 0, then all of the following functions will be no-ops, meaning that an arbitrary concurrency is allowed.

func New

func New(concurrency int) ConcurrencyLimiter

New returns a new ConcurrencyLimiter with the given limit

Jump to

Keyboard shortcuts

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