limiter

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: 0 Imported by: 2 modules, 45 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 limiter defines shared types and constants used by all limiter sub-packages (conn, rate, traffic).

Index

Constants

View Source
const (
	// ScopeService applies the limiter at the service level.
	ScopeService string = "service"
	// ScopeConn applies the limiter at the connection level.
	ScopeConn string = "conn"
	// ScopeClient applies the limiter per client (source IP).
	ScopeClient string = "client"
)

Limiter scopes define how a limiter key is interpreted.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(opts *Options)

Option is a functional option for configuring Options.

func AddrOption

func AddrOption(addr string) Option

AddrOption sets the destination address.

func ClientOption

func ClientOption(client string) Option

ClientOption sets the client identifier.

func NetworkOption

func NetworkOption(network string) Option

NetworkOption sets the network type.

func ScopeOption

func ScopeOption(scope string) Option

ScopeOption sets the limiter scope.

func ServiceOption

func ServiceOption(service string) Option

ServiceOption sets the service name.

func SrcOption

func SrcOption(src string) Option

SrcOption sets an additional source identifier.

type Options

type Options struct {
	// Service is the service name.
	Service string
	// Scope is the limiter scope ("service", "conn", or "client").
	Scope string
	// Network is the connection network type.
	Network string
	// Addr is the destination address.
	Addr string
	// Client is the client identifier (typically the source IP).
	Client string
	// Src is an additional source identifier.
	Src string
}

Options holds the parameters passed when requesting a limiter.

Directories

Path Synopsis
Package conn defines connection-level limiter interfaces for controlling the number of active connections.
Package conn defines connection-level limiter interfaces for controlling the number of active connections.
Package rate defines rate-limiting interfaces for controlling the rate of new connections or requests.
Package rate defines rate-limiting interfaces for controlling the rate of new connections or requests.
Package traffic defines bandwidth/traffic limiter interfaces for controlling data transfer rates.
Package traffic defines bandwidth/traffic limiter interfaces for controlling data transfer rates.

Jump to

Keyboard shortcuts

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