traffic

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 2 Imported by: 2 modules, 14 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package traffic defines bandwidth/traffic limiter interfaces for controlling data transfer rates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

type Limiter interface {
	// Wait blocks with the requested n bytes and returns the actual granted
	// amount, which may be less than or equal to n.
	Wait(ctx context.Context, n int) int
	// Limit returns the current rate limit in bytes per second.
	Limit() int
	// Set updates the rate limit in bytes per second.
	Set(n int)
}

Limiter controls data transfer bandwidth. It blocks until the requested amount of bytes is within the rate limit.

type TrafficLimiter

type TrafficLimiter interface {
	// In returns the Limiter for ingress (download) traffic for the given key.
	In(ctx context.Context, key string, opts ...limiter.Option) Limiter
	// Out returns the Limiter for egress (upload) traffic for the given key.
	Out(ctx context.Context, key string, opts ...limiter.Option) Limiter
}

TrafficLimiter provides per-key traffic limiters for ingress and egress traffic. This allows separate bandwidth limits per client, service, or other key dimensions.

Jump to

Keyboard shortcuts

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