Versions in this module Expand all Collapse all v0 v0.7.0 May 10, 2026 Changes in this version + var ErrAccountLocked = errors.New("account is locked") + var ErrInvalidThreshold = errors.New("invalid lockout threshold") + var ErrStorageFailure = errors.New("lockout storage failure") + type Lockout struct + func NewLockout(store LockoutStore, opts ...LockoutOption) *Lockout + func (l *Lockout) CheckAndRecord(ctx context.Context, identifier string, success bool) error + func (l *Lockout) Close() error + func (l *Lockout) GetStatus(ctx context.Context, identifier string) (LockoutStatus, error) + func (l *Lockout) IsLocked(ctx context.Context, identifier string) (bool, error) + func (l *Lockout) RecordFailure(ctx context.Context, identifier string) error + func (l *Lockout) RecordSuccess(ctx context.Context, identifier string) error + func (l *Lockout) Reset(ctx context.Context, identifier string) error + func (l *Lockout) Unlock(ctx context.Context, identifier string) error + type LockoutConfig struct + AttemptWindow time.Duration + CleanupInterval time.Duration + LockoutDuration time.Duration + MaxAttempts int + func DefaultLockoutConfig() LockoutConfig + type LockoutOption func(*Lockout) + func WithLockoutConfig(cfg LockoutConfig) LockoutOption + func WithLockoutDuration(d time.Duration) LockoutOption + func WithMaxAttempts(n int) LockoutOption + type LockoutStatus struct + FailedAttempts int + IsLocked bool + LastAttempt time.Time + LockedUntil time.Time + RemainingAttempts int + type LockoutStore interface + Close func() error + GetStatus func(ctx context.Context, identifier string, cfg LockoutConfig) (LockoutStatus, error) + Lock func(ctx context.Context, identifier string, until time.Time) error + RecordAttempt func(ctx context.Context, identifier string, success bool) error + Reset func(ctx context.Context, identifier string) error + Unlock func(ctx context.Context, identifier string) error + type MemoryLockoutOption func(*MemoryLockoutStore) + func WithLockoutCleanupInterval(d time.Duration) MemoryLockoutOption + type MemoryLockoutStore struct + func NewMemoryLockoutStore(opts ...MemoryLockoutOption) *MemoryLockoutStore + func (m *MemoryLockoutStore) Close() error + func (m *MemoryLockoutStore) GetStatus(ctx context.Context, identifier string, cfg LockoutConfig) (LockoutStatus, error) + func (m *MemoryLockoutStore) Lock(ctx context.Context, identifier string, until time.Time) error + func (m *MemoryLockoutStore) RecordAttempt(ctx context.Context, identifier string, success bool) error + func (m *MemoryLockoutStore) Reset(ctx context.Context, identifier string) error + func (m *MemoryLockoutStore) Unlock(ctx context.Context, identifier string) error + type RedisLockoutOption func(*RedisLockoutStore) + func WithLockoutKeyPrefix(prefix string) RedisLockoutOption + type RedisLockoutStore struct + func NewRedisLockoutStore(client redis.UniversalClient, opts ...RedisLockoutOption) *RedisLockoutStore + func (r *RedisLockoutStore) Close() error + func (r *RedisLockoutStore) GetStatus(ctx context.Context, identifier string, cfg LockoutConfig) (LockoutStatus, error) + func (r *RedisLockoutStore) Lock(ctx context.Context, identifier string, until time.Time) error + func (r *RedisLockoutStore) RecordAttempt(ctx context.Context, identifier string, success bool) error + func (r *RedisLockoutStore) Reset(ctx context.Context, identifier string) error + func (r *RedisLockoutStore) Unlock(ctx context.Context, identifier string) error