google / guava

Google core libraries for Java
Apache License 2.0
50.14k stars 10.89k forks source link

Allow building RateLimiter instances with Ticker #1774

Open gissuebot opened 9 years ago

gissuebot commented 9 years ago

Original issue created by itt...@wix.com on 2014-06-03 at 05:39 AM


I'd like to be able to use rateLimiter and so I need to be able to test it. I see you have a factory method which accepts a ticker but that is internal only; Such a method would help me.

gissuebot commented 9 years ago

Original comment posted by kak@google.com on 2014-06-03 at 03:57 PM


(No comment entered for this change.)


Owner: cpovirk@google.com Labels: Package-Concurrent, Type-Addition

gissuebot commented 9 years ago

Original comment posted by stephan202 on 2014-06-06 at 08:11 AM


We're not supposed to answer with "+1", but I'll do it anyway: +1. Had exactly the same observation and request.

gissuebot commented 9 years ago

Original comment posted by irvingdave1 on 2014-09-05 at 01:04 PM


This would be useful for me too. I have a simulator where there can be no coupling to 'real time' - as the code's notion of current time moving forward is driven by external events.
I have a use for a good rate limiter, but would also be able to control it's underlying ticker.

thecoop commented 7 years ago

I've also run into this issue, currently you can't use a RateLimiter in a unit test using a fake Ticker.

kluever commented 5 years ago

We allow customer Ticker instances to be provided for other APIs, so this seems reasonable.