boinkor-net / governor

A rate-limiting library for Rust (f.k.a. ratelimit_meter)
https://github.com/boinkor-net/governor
MIT License
550 stars 43 forks source link

Remove `Clock: Clone` requirement #232

Closed max-heller closed 4 months ago

max-heller commented 4 months ago

Closes #231

Also adds RateLimiter::clock() to access the clock, enabling usages like the following:

let clock = FakeClock::new();
let limiter = RateLimiter::new_with_clock(quota, clock);
limiter.clock().advance(by);

This would, for instance, enable using a FakeRelativeClock(AtomicU64) instead of having to wrap the counter in an Arc as is currently done.