Help us shape the future of Go! Take the 2026 Go Developer Survey

limit

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package limit throttles connections with a token bucket per direction.

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 is shared by every connection of one user. Upload is what the client sends, download what it receives; each direction gets the full rate.

func New

func New(bytesPerSecond uint64) *Limiter

New returns a limiter for bytesPerSecond in each direction, which must be positive.

func (*Limiter) Conn

func (l *Limiter) Conn(ctx context.Context, conn net.Conn) net.Conn

Conn throttles conn, the client side of a proxied connection.

func (*Limiter) PacketConn

func (l *Limiter) PacketConn(ctx context.Context, conn N.PacketConn) N.PacketConn

PacketConn throttles conn, the client side of a proxied packet connection.

func (*Limiter) SetLimit

func (l *Limiter) SetLimit(bytesPerSecond uint64)

SetLimit changes the rate for existing connections too.

Jump to

Keyboard shortcuts

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