gnet

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBackoff = BackoffConfig{
	MaxDelay:  120 * time.Second,
	BaseDelay: 1.0 * time.Second,
	Factor:    1.6,
	Jitter:    0.2,
}

DefaultBackoff uses values specified for backoff.

View Source
var (
	// ErrLimitListener listen limit error.
	ErrLimitListener = &LimitListenerError{}
)

Functions

func NewLimitListener

func NewLimitListener(l net.Listener, n int32) net.Listener

NewLimitListener returns a Listener that accepts at most n simultaneous connections from the provided Listener.

Types

type Backoff

type Backoff interface {
	// Backoff returns the amount of time to wait before the next retry given
	// the number of consecutive failures.
	Backoff(retries int) time.Duration
}

Backoff defines the methodology for backing off after a call failure.

type BackoffConfig

type BackoffConfig struct {
	// MaxDelay is the upper bound of backoff delay.
	MaxDelay time.Duration `json:"max_delay" yaml:"max_delay"`

	// baseDelay is the amount of time to wait before retrying after the first
	// failure.
	BaseDelay time.Duration `json:"base_delay" yaml:"base_delay"`

	// factor is applied to the backoff after each retry.
	Factor float64 `json:"factor" yaml:"factor"`

	// jitter provides a range to randomize backoff delays.
	Jitter float64 `json:"jitter" yaml:"jitter"`
}

func (*BackoffConfig) Backoff

func (bc *BackoffConfig) Backoff(retries int) time.Duration

Backoff returns the amount of time to wait before the next retry given the number of consecutive failures.

type LimitListenerError

type LimitListenerError struct{}

LimitListenerError limit max connections of listener.

func (*LimitListenerError) Error

func (l *LimitListenerError) Error() string

Error return error message of error.

func (*LimitListenerError) Temporary

func (l *LimitListenerError) Temporary() bool

Temporary is the error temporary.

func (*LimitListenerError) Timeout

func (l *LimitListenerError) Timeout() bool

Timeout is the error a timeout.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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