ratelimit

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reader

func Reader(r io.Reader, l *Limiter) io.Reader

Reader returns a reader with limiter

func Writer

func Writer(w io.Writer, l *Limiter) io.Writer

Writer returns a writer with limiter

Types

type Limiter

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

Limiter represents a rate limiter

func New

func New(rate int64) *Limiter

New create a limiter for transfer speed, parameter rate means bytes per second 0 means don't limit

func (*Limiter) Wait

func (l *Limiter) Wait(count int)

Wait sleep when write count bytes

Jump to

Keyboard shortcuts

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