limiter

package
v0.0.0-...-e282ec7 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext()

func Request

func Request(key string, count int, d time.Duration) (int, error)

Types

type Limiter

type Limiter interface {
	Request(key string, count int, d time.Duration) (int, error)
}

func NewMemoryLimiter

func NewMemoryLimiter() Limiter

func NewRedisLimiter

func NewRedisLimiter(opt *redis.Options) (Limiter, error)

type MemoryLimiter

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

func (*MemoryLimiter) Request

func (l *MemoryLimiter) Request(key string, count int, d time.Duration) (int, error)

type RedisLimiter

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

func (*RedisLimiter) Request

func (l *RedisLimiter) Request(key string, count int, d time.Duration) (int, error)

Jump to

Keyboard shortcuts

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