irc-core-2.3.0: IRC core library for glirc

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.

Synopsis

# Documentation

data RateLimit Source #

The RateLimit keeps track of rate limit settings as well as the current state of the limit.

Arguments

 :: Rational penalty seconds -> Rational threshold seconds -> IO RateLimit

Construct a new rate limit with the given penalty and threshold.

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.