Documentation
¶
Overview ¶
Package redisstore adapts a go-redis client to ratelimit.Store.
It is the only place the rate limiter touches go-redis, so consumers of the ratelimit package that bring another client, or a test double, never import go-redis.
limiter, err := ratelimit.NewWithConfig(&ratelimit.Config{
Name: "api_request",
Store: redisstore.New(redisClient.Redis()),
Rules: rules,
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNilClient = errors.New("redisstore: nil client")
ErrNilClient is returned by every call on a store built from a nil client.
Functions ¶
func New ¶
New returns a ratelimit.Store backed by client. A nil client yields a store whose calls fail with ErrNilClient, which the limiter turns into fail-open results rather than a panic at request time.
Types ¶
Click to show internal directories.
Click to hide internal directories.