wrapper

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 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 wrapper provides net.Conn and net.Listener wrappers that enforce connection limits.

Index

Constants

This section is empty.

Variables

View Source
var ErrConnLimit = errors.New("connection limit exceeded")

ErrConnLimit reports that a connection was refused because it exceeded the connection limit. It is a sentinel so callers can tell a single refused connection apart from a listener that has genuinely failed: the refusal is per-connection and leaves the listener usable, so it must not end an accept loop.

Functions

func WrapConn

func WrapConn(limiter limiter.Limiter, c net.Conn) net.Conn

WrapConn wraps a net.Conn with a connection limiter. On Close, the limiter's Allow(-1) is called to decrement the current count. If limiter is nil, the original connection is returned unchanged.

func WrapListener

func WrapListener(limiter limiter.ConnLimiter, ln net.Listener) net.Listener

WrapListener wraps a net.Listener with a ConnLimiter. Each accepted connection is checked against the limiter using the remote IP as the key. If the limit is exceeded, the connection is closed with an error. If limiter is nil, the original listener is returned unchanged.

Types

This section is empty.

Jump to

Keyboard shortcuts

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