ratelimit

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadSeeker

func ReadSeeker(rs io.ReadSeeker, l *Limiter) io.ReadSeeker

ReadSeeker 返回一个带有Limiter的io.ReadSeeker

func Reader

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

Reader 返回一个带有Limiter的io.Reader

func Writer

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

Writer 返回一个带有Limiter的io.Writer

Types

type Limiter

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

Limiter 速度限制器

func New

func New(bytesPerSecond int64) *Limiter

New 创建Limiter Usage: limiter := New(100*1024) limiter.NewReader(reader) limiter.NewWriter(writer) limiter.NewReadSeeker(readSeeker)

func (*Limiter) NewReadSeeker

func (l *Limiter) NewReadSeeker(r io.ReadSeeker) io.ReadSeeker

func (*Limiter) NewReader

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

func (*Limiter) NewWriter

func (l *Limiter) NewWriter(r io.Writer) io.Writer

func (*Limiter) Wait

func (l *Limiter) Wait(count int)

Wait 传入需要处理的数量,计算并等待需要经过的时间

Jump to

Keyboard shortcuts

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