rate-limit 1.0.0 → 1.1.0
raw patch · 2 files changed
+16/−12 lines, 2 files
Files
- Control/RateLimit.hs +15/−11
- rate-limit.cabal +1/−1
Control/RateLimit.hs view
@@ -30,6 +30,11 @@ -- module Control.RateLimit( generateRateLimitedFunction+ , RateLimit+ , ResultsCombiner+ , dontCombine+ , rateLimitInvocation+ , rateLimitExecution ) where @@ -38,6 +43,7 @@ import Control.Monad(when) import Data.Time.Units +-- |The rate at which to limit an action. data TimeUnit a => RateLimit a = PerInvocation a -- ^Rate limit the action to invocation once per time -- unit. With this option, the time it takes for the@@ -94,17 +100,15 @@ -- |The most generic way to rate limit an invocation. generateRateLimitedFunction :: TimeUnit t =>- RateLimit t ->- (req -> IO resp) ->- ResultsCombiner req resp ->- IO (req -> IO resp)-generateRateLimitedFunction- ratelimit -- ^What is the rate limit for this action?- action -- ^What is the action you want to rate limit, given as an- -- a MonadIO function from requests to responses?- combiner -- ^A function that can combine requests if rate limiting- -- happens. If you cannot combine two requests into one- -- request, we suggest using 'dontCombine'.+ RateLimit t -- ^What is the rate limit for this action+ -> (req -> IO resp) -- ^What is the action you want to rate limit, given as an+ -- a MonadIO function from requests to responses?+ -> ResultsCombiner req resp -- ^A function that can combine requests if rate+ -- limiting happens. If you cannot combine two+ -- requests into one request, we suggest using+ -- 'dontCombine'.+ -> IO (req -> IO resp)+generateRateLimitedFunction ratelimit action combiner = do chan <- newChan forkIO $ runner (-42) chan return $ resultFunction chan
rate-limit.cabal view
@@ -1,5 +1,5 @@ Name: rate-limit-Version: 1.0.0+Version: 1.1.0 Build-Type: Simple Cabal-Version: >= 1.6 License: BSD3