irc-core-1.1.1.1: An IRC client library and text client

Safe HaskellSafe
LanguageHaskell2010

Irc.RateLimit

Description

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.

Synopsis

Documentation

data RateLimit Source

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

newRateLimit Source

Arguments

:: Int

penalty

-> Int

threshold

-> IO RateLimit 

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.