pacelimiter

package
v1.41.0-cluster Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PaceLimiter

type PaceLimiter struct {
	// contains filtered or unexported fields
}

PaceLimiter throttles WaitIfNeeded callers while the number of Inc calls is bigger than the number of Dec calls.

It is expected that Inc is called before performing high-priority work, while Dec is called when the work is done. WaitIfNeeded must be called inside the work which must be throttled (i.e. lower-priority work). It may be called in the loop before performing a part of low-priority work.

func New

func New() *PaceLimiter

New returns pace limiter that throttles WaitIfNeeded callers while the number of Inc calls is bigger than the number of Dec calls.

func (*PaceLimiter) Dec

func (pl *PaceLimiter) Dec()

Dec decrements pl.

func (*PaceLimiter) DelaysTotal

func (pl *PaceLimiter) DelaysTotal() uint64

DelaysTotal returns the number of delays inside WaitIfNeeded.

func (*PaceLimiter) Inc

func (pl *PaceLimiter) Inc()

Inc increments pl.

func (*PaceLimiter) WaitIfNeeded

func (pl *PaceLimiter) WaitIfNeeded()

WaitIfNeeded blocks while the number of Inc calls is bigger than the number of Dec calls.

Jump to

Keyboard shortcuts

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