netlimit

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package netlimit bounds the number of connections accepted across one or more listeners. Pending clients remain in the kernel listen backlog and do not consume a process file descriptor until a shared slot is available.

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 a shared accepted-connection budget. Wrap every listener that should draw from the same process-wide allowance.

func New

func New(max int) *Limiter

func (*Limiter) Capacity

func (l *Limiter) Capacity() int

func (*Limiter) InUse

func (l *Limiter) InUse() int

func (*Limiter) Wrap

func (l *Limiter) Wrap(inner net.Listener) net.Listener

Wrap returns a listener whose accepted connections hold one shared slot until Close. The slot is acquired before Accept, so accepted process FDs can never exceed Capacity even when multiple wrapped listeners are serving.

Jump to

Keyboard shortcuts

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