throt

package
v0.0.0-...-1c8de56 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Per

func Per(eventCount int, duration time.Duration) rate.Limit

Per sets rate limit. Returns rate.Inf if duration is zero.

Types

type Limiter

type Limiter interface {
	Wait(context.Context) error
	Limit() rate.Limit
}

Limiter limits the rate per second and/or minute

func NewMultiLimiter

func NewMultiLimiter(args *MultiLimitArgs) (limiter Limiter, err error)

NewMultiLimiter limits the rate using multiple limiters.

type MultiLimitArgs

type MultiLimitArgs struct {
	CxnNum  uint
	RateSec uint
	RateMin uint
}

MultiLimitArgs used to configure the limiter.

type MultiLimiter

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

MultiLimiter throttles transactions

func (*MultiLimiter) Limit

func (l *MultiLimiter) Limit() rate.Limit

Limit returns the most restrictive rate limiter.

func (*MultiLimiter) Wait

func (l *MultiLimiter) Wait(ctx context.Context) error

Wait blocks to limit the rate by using every encapsulted limiter.

Jump to

Keyboard shortcuts

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