cockroach: Index | Files

package limit

import ""


Package Files

limiter.go rate_limiter.go

type ConcurrentRequestLimiter Uses

type ConcurrentRequestLimiter struct {
    // contains filtered or unexported fields

ConcurrentRequestLimiter wraps a simple semaphore, adding a tracing span when a request is forced to wait.

func MakeConcurrentRequestLimiter Uses

func MakeConcurrentRequestLimiter(spanName string, limit int) ConcurrentRequestLimiter

MakeConcurrentRequestLimiter creates a ConcurrentRequestLimiter.

func (*ConcurrentRequestLimiter) Begin Uses

func (l *ConcurrentRequestLimiter) Begin(ctx context.Context) error

Begin attempts to reserve a spot in the pool, blocking if needed until the one is available or the context is canceled and adding a tracing span if it is forced to block.

func (*ConcurrentRequestLimiter) Finish Uses

func (l *ConcurrentRequestLimiter) Finish()

Finish indicates a concurrent request has completed and its reservation can be returned to the pool.

func (*ConcurrentRequestLimiter) SetLimit Uses

func (l *ConcurrentRequestLimiter) SetLimit(newLimit int)

SetLimit adjusts the size of the pool.

type LimiterBurstDisabled Uses

type LimiterBurstDisabled struct {
    // contains filtered or unexported fields

LimiterBurstDisabled is used to solve a complication in rate.Limiter. The rate.Limiter requires a burst parameter and if the throttled value exceeds the burst it just fails. This not always the desired behavior, sometimes we want the limiter to apply the throttle and not enforce any hard limits on an arbitrarily large value. This feature is particularly useful in Cockroach, when we want to throttle on the KV pair, the size of which is not strictly enforced.

func NewLimiter Uses

func NewLimiter(r rate.Limit) *LimiterBurstDisabled

NewLimiter returns a new LimiterBurstDisabled that allows events up to rate r.

func (*LimiterBurstDisabled) WaitN Uses

func (lim *LimiterBurstDisabled) WaitN(ctx context.Context, n int) error

WaitN blocks until lim permits n events to happen.

This function will now only return an error if the Context is canceled and should never in practice hit the burst check in the underlying limiter.

Package limit imports 5 packages (graph) and is imported by 17 packages. Updated 2020-08-13. Refresh now. Tools for package owners.