Closed isaachier closed 6 years ago
@yurishkuro the reason this is in jaeger-lib was to migrate it from jaeger-client-go. But @black-adder had said that using utils.RateLimiter
from jaeger-lib instead of jaeger-client-go would be a potential issue for backwards-compatibility (he might remember details, I'm not sure at the moment), which is why utils.RateLimiter
has not been removed from the client.
Regarding the reuse of this rate limiter, I believe it should be done once well, instead of ad-hoc in each library. One API change was discussed and ultimately dismissed in #38. For that reason, the throttler in https://github.com/jaegertracing/jaeger/pull/1079 uses a custom token bucket implementation. Not adding the wait time API here would mean implementing yet another custom token bucket implementation.
Build fix depends on #56.
It is much easier to make internal type public than vice versa. You are currently trying to solve exactly one use case, which does not meet the "rule of three" condition for being public type. Also, as Prithvi suggested, why can we not just use uber-go rate limiter, which already sleeps? Let's solve problems by writing less code, not more.
I didn't realize uber-go was an option (adding dependencies being frowned upon). Either way, I'm happy. Lol about "rule of three" (never heard outside of C++). But I think it does solve three unique cases:
All three cases need the simple token bucket implementation, so I don't see why it is not just done full scale here.
Bottom line: what do you suggest?
I suggest either using uber-go limiter or an internal type. While we do have three use cases, they all have slightly different requirements and developing a single solution with a written-in-stone API is something I personally want to avoid. If anything, we can try to combine throttler with this one, but still as internal type where we don't have to worry about public API.
Got it. Thanks!
BTW uber-go/ratelimit only takes an integer credits per second.
Which problem is this PR solving?
52
Short description of the changes