ratelimit

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ratelimit provides an interface and implementation for rate limiting functionality, specifically for OTP requests in the authentication flow. It defines the RatelimitStore interface and a Redis-based implementation to track and enforce request limits based on email addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryRateLimitStore

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

MemoryRateLimitStore holds the state for the in-memory rate limiters.

func NewMemoryRateLimitStore

func NewMemoryRateLimitStore(cleanupInterval time.Duration) *MemoryRateLimitStore

NewMemoryRateLimitStore creates a new store and starts the cleanup goroutine.

func (*MemoryRateLimitStore) Allow

func (s *MemoryRateLimitStore) Allow(ctx context.Context, key string, limit int, period time.Duration) (bool, time.Duration, error)

Allow implements domain.RateLimitStore.

func (*MemoryRateLimitStore) Close

func (s *MemoryRateLimitStore) Close()

Close stops the cleanup goroutine.

Jump to

Keyboard shortcuts

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