Documentation
¶
Overview ¶
Package securitylimit provides the shared backend for security-sensitive limits.
Index ¶
- Constants
- type Bucket
- type Decision
- type Limiter
- type Memory
- func (m *Memory) Peek(ctx context.Context, spec Window, key string) (Decision, error)
- func (m *Memory) Record(ctx context.Context, spec Window, key string) (Decision, error)
- func (m *Memory) Reset(ctx context.Context, spec Window, key string) error
- func (m *Memory) Size(name string) int
- func (m *Memory) Take(ctx context.Context, spec Bucket, key string) (Decision, error)
- type Window
Constants ¶
const DefaultMaxKeysPerName = 8192
DefaultMaxKeysPerName is the per-name cap used when NewMemory gets no positive cap.
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, b Bucket, key string) (Decision, error)
Peek(ctx context.Context, w Window, key string) (Decision, error)
Record(ctx context.Context, w Window, key string) (Decision, error)
Reset(ctx context.Context, w Window, 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 NewMemory ¶
NewMemory returns an in-memory limiter with the production clock and key cap when the corresponding arguments are nil or non-positive.