limiter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: BSD-2-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServerLimiter

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

ServerLimiter provides interface to limit amount of requests

func NewServerLimiter

func NewServerLimiter(servers []string, l int) ServerLimiter

NewServerLimiter creates a limiter for specific servers list.

func (ServerLimiter) Enter

func (sl ServerLimiter) Enter(s string)

Enter claims one of free slots or blocks until there is one.

func (ServerLimiter) Leave

func (sl ServerLimiter) Leave(s string)

Frees a slot in limiter

func (ServerLimiter) LimiterUse

func (sl ServerLimiter) LimiterUse() map[string]float64

LimiterUse returns the ratio of limiter saturation as a float between 0 and 1 per limiter.

func (ServerLimiter) MaxLimiterUse

func (sl ServerLimiter) MaxLimiterUse() float64

MaxLimiterUse returns the maximum ratio of limiter saturation in the ServerLimiter as a float between 0 and 1.

Jump to

Keyboard shortcuts

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