Consider adding an auto close option to Throttler
Given that:
If a Bucket (key, rate) doesn't exist yet, it is created.
and
You must call Close when you're done with the Throttler in order to not leak a go-routine and a system-timer.
Wouldn't be nice to have an option to auto close buckets once they are full for n ticks?
Thanks
Hello,
I'm not entirely happy with the API I designed here. With that said, buckets aren't supposed to be Closed once they're full. Would you elucidate me on your use case?
If you wanted to use this library to rate limit an API or something, say based on an IP address or some kind of unbound data (auth token or whatever), then memory is going to grow over time.
Having a method to reclaim memory if the bucket isn't used for a while would be useful.
Unfortunately I currently don't have time to work on this library. I'd recommend building something on top of https://github.com/juju/ratelimit