connlimit

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 5 Imported by: 95

Documentation

Overview

Package connlimit provides control over simultaneous connections coming from the same source

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnErrHandler

type ConnErrHandler struct {
	// contains filtered or unexported fields
}

ConnErrHandler connection limiter error handler.

func (*ConnErrHandler) ServeHTTP

func (e *ConnErrHandler) ServeHTTP(w http.ResponseWriter, req *http.Request, err error)

type ConnLimitOption

type ConnLimitOption = Option

ConnLimitOption connection limit option type. Deprecated: use Option instead.

type ConnLimiter

type ConnLimiter struct {
	// contains filtered or unexported fields
}

ConnLimiter tracks concurrent connection per token and is capable of rejecting connections if they are failed.

func New

func New(next http.Handler, extract utils.SourceExtractor, maxConnections int64, options ...Option) (*ConnLimiter, error)

New creates a new ConnLimiter.

func (*ConnLimiter) ServeHTTP

func (cl *ConnLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ConnLimiter) Wrap

func (cl *ConnLimiter) Wrap(h http.Handler)

Wrap sets the next handler to be called by connection limiter handler.

type MaxConnError

type MaxConnError struct {
	// contains filtered or unexported fields
}

MaxConnError maximum connections reached error.

func (*MaxConnError) Error

func (m *MaxConnError) Error() string

type Option added in v1.4.0

type Option func(l *ConnLimiter) error

Option connection limit option type.

func ErrorHandler

func ErrorHandler(h utils.ErrorHandler) Option

ErrorHandler sets error handler of the server.

func Logger

func Logger(l *log.Logger) Option

Logger defines the logger the connection limiter will use.

It defaults to logrus.StandardLogger(), the global logger used by logrus.

Jump to

Keyboard shortcuts

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