pachyderm: Index | Files

package limit

import ""

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.


Package Files


type ConcurrencyLimiter Uses

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

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 Uses

func New(concurrency int) ConcurrencyLimiter

New returns a new ConcurrencyLimiter with the given limit

Package limit is imported by 12 packages. Updated 2019-02-24. Refresh now. Tools for package owners.