limiter

package
v1.102.1-cluster Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

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

Limiter controls the amount of budget that can be spent according to configured perSecondLimit

func NewLimiter

func NewLimiter(perSecondLimit int64) *Limiter

NewLimiter creates a Limiter object for the given perSecondLimit

func (*Limiter) Register

func (l *Limiter) Register(dataLen int)

Register blocks for amount of time needed to process the given dataLen according to the configured perSecondLimit.

type WriteLimiter

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

WriteLimiter limits the amount of bytes written per second via Write() method. Must be created via NewWriteLimiter.

func NewWriteLimiter

func NewWriteLimiter(w io.Writer, limiter *Limiter) *WriteLimiter

NewWriteLimiter creates a new WriteLimiter object for the give writer and Limiter.

func (*WriteLimiter) Close

func (wl *WriteLimiter) Close() error

Close implements io.Closer also calls Close for wrapped io.WriteCloser

func (*WriteLimiter) Write

func (wl *WriteLimiter) Write(p []byte) (n int, err error)

Write implements io.Writer

Jump to

Keyboard shortcuts

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