Documentation
¶
Overview ¶
Package securitylimit provides the shared backend for security-sensitive limits.
Index ¶
- type Decision
- type Limiter
- type Memory
- func (m *Memory) CheckWindow(ctx context.Context, name, key string, now time.Time, limit int, ...) (Decision, error)
- func (m *Memory) FailWindow(ctx context.Context, name, key string, now time.Time, duration time.Duration, ...) error
- func (m *Memory) RecordWindow(ctx context.Context, name, key string, now time.Time, limit int, ...) (Decision, error)
- func (m *Memory) Reset(ctx context.Context, name, key string) error
- func (m *Memory) Size(name string) int
- func (m *Memory) Take(ctx context.Context, name, key string, now time.Time, burst float64, ...) (Decision, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decision ¶
Decision describes a limiter operation. First is set on the first request that reaches a window limit, so callers can report that lockout once.
type Limiter ¶
type Limiter interface {
Take(ctx context.Context, name, key string, now time.Time, burst float64, refill time.Duration, cost float64) (Decision, error)
CheckWindow(ctx context.Context, name, key string, now time.Time, limit int, window time.Duration, maxKeys int, touch bool) (Decision, error)
RecordWindow(ctx context.Context, name, key string, now time.Time, limit int, window time.Duration, maxKeys int) (Decision, error)
FailWindow(ctx context.Context, name, key string, now time.Time, window time.Duration, maxKeys int) error
Reset(ctx context.Context, name, key string) error
}
Limiter covers token buckets and bounded failure windows used by security checks.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is the VPS implementation. Names isolate each limiter's key space.
func (*Memory) CheckWindow ¶
func (*Memory) FailWindow ¶
func (m *Memory) FailWindow(ctx context.Context, name, key string, now time.Time, duration time.Duration, maxKeys int) error
FailWindow adds a failed attempt without a threshold check. It is paired with CheckWindow when the caller only counts failed operations, as Enroll does.