Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module implements a simple rate limiter based on the to be used to keep an IRC client from getting kicked due to flooding. It allows one event per duration with a given threshold.
- data RateLimit
- newRateLimit :: Int -> Int -> IO RateLimit
- newRateLimitDefault :: IO RateLimit
- tickRateLimit :: RateLimit -> IO ()
Documentation
The RateLimit
keeps track of rate limit settings as well
as the current state of the limit.
Construct a new rate limit with the given penalty and threshold.
newRateLimitDefault :: IO RateLimit Source
Construct a new rate limit with the RFC 2813 specified 2 second penalty and 10 second threshold
tickRateLimit :: RateLimit -> IO () Source
Account for an event in the context of a RateLimit
. This command
will block and delay as required to satisfy the current rate. Once
it returns it is safe to proceed with the rate limited action.