limiter

package
v0.12.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: BSD-2-Clause Imports: 2 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) Capacity added in v0.12.0

func (sl ServerLimiter) Capacity() int

func (ServerLimiter) Enter

func (sl ServerLimiter) Enter(ctx context.Context, s string) error

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

func (ServerLimiter) Leave

func (sl ServerLimiter) Leave(ctx context.Context, s string)

Frees a slot in limiter

type SimpleLimiter added in v0.12.0

type SimpleLimiter chan struct{}

func NewSimpleLimiter added in v0.12.0

func NewSimpleLimiter(l int) SimpleLimiter

func (SimpleLimiter) Enter added in v0.12.0

func (l SimpleLimiter) Enter()

func (SimpleLimiter) Leave added in v0.12.0

func (l SimpleLimiter) Leave()

Jump to

Keyboard shortcuts

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