
Golang implementation of Sliding Window Algorithm for distributed rate limiting - russellluo
https://github.com/RussellLuo/slidingwindow
======
sidlls
That's a neat little lib. One possible nitpick: the redis integration should
be reconsidered. The limiter's interface provides a mechanism for someone
using this library to implement their own integration, which permits
flexibility in both the choice of redis client and usage of this code.

~~~
russellluo
Hi sidlls, thanks for your attention!

If I understand you correctly, by saying "the redis integration should be
reconsidered", you means the
[RedisClient]([https://godoc.org/github.com/RussellLuo/slidingwindow#RedisC...](https://godoc.org/github.com/RussellLuo/slidingwindow#RedisClient))
interface is [go-redis]([https://github.com/go-
redis/redis](https://github.com/go-redis/redis)) specific, is that right?

~~~
sidlls
Actually I mean if I were maintaining this I'd probably not include such an
interface at all, and let users of the library decide it entirely.

~~~
russellluo
I got it, thanks for your advice!

`RedisDatastore` is entirely removed, and it only serves as a reference
implementation in tests now.

------
russellluo
For guys who are interested, Limiter is now optimized to only consume at most
one goroutine for the possible sync behaviour (within the current window).

