Documentation ¶
Overview ¶
krakendrate contains a collection of curated rate limit adaptors for the KrakenD framework
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrLimited is the error returned when the rate limit has been exceded ErrLimited = errors.New("ERROR: rate limit exceded") // DataTTL is the default eviction time DataTTL = 10 * time.Minute )
Functions ¶
func PseudoFNV64a ¶ added in v1.4.1
Types ¶
type Backend ¶
type Backend interface { Load(string, func() interface{}) interface{} Store(string, interface{}) error }
Backend is the interface of the persistence layer
type Limiter ¶
type Limiter interface {
Allow() bool
}
Limiter defines a simple interface for a rate limiter
type LimiterStore ¶
LimiterStore defines the interface for a limiter lookup function
type MemoryBackend ¶
type MemoryBackend struct {
// contains filtered or unexported fields
}
MemoryBackend implements the backend interface by wrapping a sync.Map
func NewMemoryBackend ¶
func NewMemoryBackend(ctx context.Context, ttl time.Duration) *MemoryBackend
func (*MemoryBackend) Load ¶
func (m *MemoryBackend) Load(key string, f func() interface{}) interface{}
Load implements the Backend interface
func (*MemoryBackend) Store ¶
func (m *MemoryBackend) Store(key string, v interface{}) error
Store implements the Backend interface
type ShardedMemoryBackend ¶ added in v1.4.1
type ShardedMemoryBackend struct {
// contains filtered or unexported fields
}
ShardedMemoryBackend is a memory backend shardering the data in order to avoid mutex contention
func DefaultShardedMemoryBackend ¶ added in v1.4.1
func DefaultShardedMemoryBackend(ctx context.Context) *ShardedMemoryBackend
DefaultShardedMemoryBackend is a 2018 sharded ShardedMemoryBackend
func NewShardedMemoryBackend ¶ added in v1.4.1
func NewShardedMemoryBackend(ctx context.Context, shards uint64, ttl time.Duration, h Hasher) *ShardedMemoryBackend
NewShardedMemoryBackend returns a ShardedMemoryBackend with 'shards' shards
func (*ShardedMemoryBackend) Load ¶ added in v1.4.1
func (b *ShardedMemoryBackend) Load(key string, f func() interface{}) interface{}
Load implements the Backend interface
func (*ShardedMemoryBackend) Store ¶ added in v1.4.1
func (b *ShardedMemoryBackend) Store(key string, v interface{}) error
Store implements the Backend interface
Directories ¶
Path | Synopsis |
---|---|
Package juju provides a set of rate-limit proxy and router middlewares using the github.com/juju/ratelimit lib.
|
Package juju provides a set of rate-limit proxy and router middlewares using the github.com/juju/ratelimit lib. |
proxy
Package proxy provides a rate-limit proxy middleware using the github.com/juju/ratelimit lib.
|
Package proxy provides a rate-limit proxy middleware using the github.com/juju/ratelimit lib. |
router
Package router provides several rate-limit routers using the github.com/juju/ratelimit lib.
|
Package router provides several rate-limit routers using the github.com/juju/ratelimit lib. |
Package rate provides a set of rate-limit proxy and router middlewares using the golang.org/x/time/rate lib.
|
Package rate provides a set of rate-limit proxy and router middlewares using the golang.org/x/time/rate lib. |
proxy
Package proxy provides a rate-limit proxy middleware using the golang.org/x/time/rate lib.
|
Package proxy provides a rate-limit proxy middleware using the golang.org/x/time/rate lib. |
router
Package router provides several rate-limit routers using the golang.org/x/time/rate lib.
|
Package router provides several rate-limit routers using the golang.org/x/time/rate lib. |