go-redis / redis_rate

Rate limiting for go-redis

Home Page:https://redis.uptrace.dev/guide/go-redis-rate-limiting.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

README.md Example Does Not Work - Rate Library Function Signature Changed

jonmchan opened this issue · comments

The example in the README.md no longer works. The call rate.NewLimiter has a new method signature which requires an additional parameter.

Here are the following errors when I try to run the example code verbatim:

main/main.go:49: not enough arguments in call to rate.NewLimiter
main/main.go:51: limiter.Fallback undefined (type *rate.Limiter has no field or method Fallback)
main/main.go:51: undefined: timerate in timerate.NewLimiter
main/main.go:54: cannot use limiter (type *rate.Limiter) as type *redis_rate.Limiter in argument to handler
main/main.go:58: cannot use limiter (type *rate.Limiter) as type *redis_rate.Limiter in argument to statusHandler

It looks like you are using old version of redis_rate. Please try go get -u github.com/go-redis/redis_rate.