backends

package
v1.0.40 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCompositeKey

func CreateCompositeKey(dimensions map[string]string) string

CreateCompositeKey creates a composite key for multi-dimensional rate limiting

Types

type DynamORMBackend

type DynamORMBackend struct {
}

DynamORMBackend implements the Limited library backend interface using DynamORM Note: This is a placeholder implementation. The actual implementation would depend on the DynamORM client being available in the Lambda runtime.

func NewDynamORMBackend

func NewDynamORMBackend() *DynamORMBackend

NewDynamORMBackend creates a new DynamORM backend for the Limited library

func (*DynamORMBackend) Cleanup

func (b *DynamORMBackend) Cleanup(ctx context.Context) error

Cleanup removes expired entries (usually handled by DynamoDB TTL)

func (*DynamORMBackend) Get

func (b *DynamORMBackend) Get(ctx context.Context, key string, window time.Time) (int64, error)

Get retrieves the current count for the given key and window

func (*DynamORMBackend) GetMultiple

func (b *DynamORMBackend) GetMultiple(ctx context.Context, key string, windows []time.Time) (map[time.Time]int64, error)

GetMultiple retrieves counts for multiple windows (for sliding window rate limiting)

func (*DynamORMBackend) Increment

func (b *DynamORMBackend) Increment(ctx context.Context, key string, window time.Time) (int64, error)

Increment atomically increments the counter for the given key and window

func (*DynamORMBackend) IncrementBy

func (b *DynamORMBackend) IncrementBy(ctx context.Context, key string, window time.Time, amount int64) (int64, error)

IncrementBy atomically increments the counter by the specified amount

func (*DynamORMBackend) Reset

func (b *DynamORMBackend) Reset(ctx context.Context, key string, window time.Time) error

Reset removes the rate limit entry for the given key and window

func (*DynamORMBackend) SetMetadata

func (b *DynamORMBackend) SetMetadata(ctx context.Context, key string, window time.Time, metadata map[string]string) error

SetMetadata associates metadata with a rate limit key (e.g., IP, UserID, TenantID)

Jump to

Keyboard shortcuts

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