limit

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2018 License: Apache-2.0 Imports: 0 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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