ratelimiter

package
v0.0.0-...-102a0e7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoginAttemptLimiter

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

LoginAttemptLimiter ログイン試行専用のレート制限

func NewLoginAttemptLimiter

func NewLoginAttemptLimiter(rateLimiter RateLimiter, maxAttempts int, window time.Duration) *LoginAttemptLimiter

NewLoginAttemptLimiter 新しいLoginAttemptLimiterを作成

func (*LoginAttemptLimiter) CheckAttempt

func (l *LoginAttemptLimiter) CheckAttempt(ctx context.Context, identifier string) (bool, int, time.Duration, error)

CheckAttempt ログイン試行が許可されているかチェック

func (*LoginAttemptLimiter) ResetAttempts

func (l *LoginAttemptLimiter) ResetAttempts(ctx context.Context, identifier string) error

ResetAttempts 指定された識別子のログイン試行回数をリセット

type RateLimiter

type RateLimiter interface {
	// IsAllowed 指定されたキーに対してアクションが許可されているかチェック
	IsAllowed(ctx context.Context, key string, limit int, window time.Duration) (bool, int, time.Duration, error)
	// Reset 指定されたキーのレート制限をリセット
	Reset(ctx context.Context, key string) error
}

RateLimiter Redisベースのレート制限インターフェース

func NewRedisRateLimiter

func NewRedisRateLimiter(client rueidis.Client) RateLimiter

NewRedisRateLimiter 新しいRedisRateLimiterを作成

type RedisRateLimiter

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

RedisRateLimiter Redisを使用したレート制限実装

func (*RedisRateLimiter) IsAllowed

func (r *RedisRateLimiter) IsAllowed(ctx context.Context, key string, limit int, window time.Duration) (bool, int, time.Duration, error)

IsAllowed スライディングウィンドウ方式でレート制限をチェック 戻り値: (許可されているか, 残り試行回数, リセットまでの時間, エラー)

func (*RedisRateLimiter) Reset

func (r *RedisRateLimiter) Reset(ctx context.Context, key string) error

Reset 指定されたキーのレート制限をリセット

type RegisterAttemptLimiter

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

RegisterAttemptLimiter 登録試行専用のレート制限

func NewRegisterAttemptLimiter

func NewRegisterAttemptLimiter(rateLimiter RateLimiter, maxAttempts int, window time.Duration) *RegisterAttemptLimiter

NewRegisterAttemptLimiter 新しいRegisterAttemptLimiterを作成

func (*RegisterAttemptLimiter) CheckAttempt

func (r *RegisterAttemptLimiter) CheckAttempt(ctx context.Context, identifier string) (bool, int, time.Duration, error)

CheckAttempt 登録試行が許可されているかチェック

func (*RegisterAttemptLimiter) ResetAttempts

func (r *RegisterAttemptLimiter) ResetAttempts(ctx context.Context, identifier string) error

ResetAttempts 指定された識別子の登録試行回数をリセット

Jump to

Keyboard shortcuts

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