ratelimit

package
v0.0.0-...-dde7ba0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultLimiter

func NewDefaultLimiter(reqPerSec float64, burst int) limiter.Limiter

Types

type GoRedis

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

func NewGoRedis

func NewGoRedis(rdb *redis.Client, rps float64, burst int) *GoRedis

func (*GoRedis) Allow

func (d *GoRedis) Allow(key string) (bool, error)

func (*GoRedis) AllowN

func (d *GoRedis) AllowN(key string, n int) (bool, error)

type Mutex

type Mutex struct {
	M map[string]limiter.Limiter
	R float64
	B int
	// contains filtered or unexported fields
}

func NewMutex

func NewMutex(constuctor NewLimiterFn, reqPerSec float64, burst int) *Mutex

func (*Mutex) Allow

func (d *Mutex) Allow(key string) (bool, error)

type NewLimiterFn

type NewLimiterFn = func(rate float64, burst int) limiter.Limiter

type RWMutex

type RWMutex struct {
	M map[string]limiter.Limiter
	R float64
	B int
	// contains filtered or unexported fields
}

func NewRWMutex

func NewRWMutex(constructor NewLimiterFn, reqPerSec float64, burst int) *RWMutex

func (*RWMutex) Allow

func (d *RWMutex) Allow(key string) (bool, error)

type Ratelimiter

type Ratelimiter interface {
	Allow(string) (bool, error)
}

func NewDefaultRatelimiter

func NewDefaultRatelimiter(reqPerSec float64, burst int) Ratelimiter

type SyncMapLoadOrStore

type SyncMapLoadOrStore struct {
	R float64
	B int
	// contains filtered or unexported fields
}

func NewSyncMapLoadOrStore

func NewSyncMapLoadOrStore(constructor NewLimiterFn, reqPerSec float64, burst int) *SyncMapLoadOrStore

func (*SyncMapLoadOrStore) Allow

func (d *SyncMapLoadOrStore) Allow(key string) (bool, error)

type SyncMapLoadThenLoadOrStore

type SyncMapLoadThenLoadOrStore struct {
	R float64
	B int
	// contains filtered or unexported fields
}

func NewSyncMapLoadThenLoadOrStore

func NewSyncMapLoadThenLoadOrStore(constructor NewLimiterFn, reqPerSec float64, burst int) *SyncMapLoadThenLoadOrStore

func (*SyncMapLoadThenLoadOrStore) Allow

func (d *SyncMapLoadThenLoadOrStore) Allow(key string) (bool, error)

type SyncMapLoadThenStore

type SyncMapLoadThenStore struct {
	R float64
	B int
	// contains filtered or unexported fields
}

func NewSyncMapLoadThenStore

func NewSyncMapLoadThenStore(constructor NewLimiterFn, reqPerSec float64, burst int) *SyncMapLoadThenStore

func (*SyncMapLoadThenStore) Allow

func (d *SyncMapLoadThenStore) Allow(key string) (bool, error)

Jump to

Keyboard shortcuts

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