The internal and external interface in ratelimit_meter has long been a thorn in my thigh: We have three implementations of state-keeping (two really, the Allower almost doesn't count), and using ratelimit_meter means having to import traits left and right.
Well, this PR changes all that! It:
Restructures all the rate limiting implementations so that they are stateless & only provide the bare algorithm and data structure access abstractions.
Introduces a new structure DirectRateLimiter that keeps state and can be parameterized with any of the three rate limiting strategies.
[x] make the tests run on bare algorithms and on all the rate limiter structures now.
[x] better constructors for keyed rate limiters (this should really get a builder, especially for customizing the evmap).
[x] add a test for expiry from the keyed rate limiter
[x] make NonConformance an associated type on the rate limiter algorithm & implement traits on each.
The internal and external interface in ratelimit_meter has long been a thorn in my thigh: We have three implementations of state-keeping (two really, the Allower almost doesn't count), and using ratelimit_meter means having to import traits left and right.
Well, this PR changes all that! It:
Restructures all the rate limiting implementations so that they are stateless & only provide the bare algorithm and data structure access abstractions.
Introduces a new structure
DirectRateLimiter
that keeps state and can be parameterized with any of the three rate limiting strategies.[x] make the tests run on bare algorithms and on all the rate limiter structures now.
[x] better constructors for keyed rate limiters (this should really get a builder, especially for customizing the evmap).
[x] add a test for expiry from the keyed rate limiter
[x] make
NonConformance
an associated type on the rate limiter algorithm & implement traits on each.