| Copyright | (c) Eric Mertens, 2016 |
|---|---|
| License | ISC |
| Maintainer | emertens@gmail.com |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Irc.RateLimit
Description
This module implements a simple rate limiter based on the IRC RFC to be used to keep an IRC client from getting disconnected for flooding. It allows one event per duration with a given threshold.
This algorithm keeps track of the time at which the client may
start sending messages. Each message sent advances that time into
the future by the penalty. The client is allowed to transmit
up to threshold seconds ahead of this time.
- data RateLimit
- newRateLimit :: Rational -> Rational -> 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.