This library provides a simple sliding log rate limiter. It should be fed a Posix.Posix using a Time.every subscription.
Type representing a rate limiter
Try to execute an operation. If allowed, the accept function is called with an updated RateLimiter instance and then returned. If not allowed, the reject argument is returned.
let
accept =
\rl -> ( { model | rateLimiter = rl }, expensiveHttpRequest RequestCompleted } )
in
RateLimiter.trigger rateLimiter identifier accept ( model, Cmd.none )One and a half hours
hours 1.55 minutes
minutes 510 seconds
seconds 10A single day
days 1A week
weeks 1
Create a sliding log rate limiter that allows 5 operations every 5 minutes.