limiter

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available(group string, f WeightFunc) gin.HandlerFunc

Types

type Blocker

type Blocker interface {
	BlockUntil(id, cause string, exp time.Time) error
	State(id string) (exp time.Time, cause string, blocked bool)
	Clean(id string) error
}

func NewBlocker

func NewBlocker(c *redis.Client, maxAge time.Duration) Blocker

type Limiter

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

func NewLimiter

func NewLimiter(addr string, password string, db int) (*Limiter, error)

func NewLimiterWithClient

func NewLimiterWithClient(c *redis.Client) (*Limiter, error)

func (*Limiter) AddGroup

func (limiter *Limiter) AddGroup(group string, max int, window time.Duration)

func (*Limiter) Available

func (limiter *Limiter) Available(key, group string, weight int) (int, error)

func (*Limiter) Clear

func (limiter *Limiter) Clear(key, group string) error

func (*Limiter) Limit

func (limiter *Limiter) Limit() gin.HandlerFunc

type WeightFunc

type WeightFunc func(c *gin.Context) int

func Weight

func Weight(w int) WeightFunc

Jump to

Keyboard shortcuts

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