ratelimit

package
v0.0.0-...-eb082ec Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInMemory

func NewInMemory() *inMemory

func NewRedis

func NewRedis(config RedisConfig) (*redisRateLimiter, error)

Types

type RatelimitRequest

type RatelimitRequest struct {
	Identifier     string
	Max            int64
	RefillRate     int64
	RefillInterval int64
}

type RatelimitResponse

type RatelimitResponse struct {
	Pass      bool
	Limit     int64
	Remaining int64
	Reset     int64
}

type Ratelimiter

type Ratelimiter interface {
	Take(req RatelimitRequest) RatelimitResponse
}

type RedisConfig

type RedisConfig struct {
	RedisUrl string
	Logger   *zap.Logger
}

Jump to

Keyboard shortcuts

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