multitasking
Safe HaskellNone
LanguageGHC2021

Multitasking.RateLimit

Contents

Synopsis

Throttling

data RateLimit Source #

Specifies a rate limit which can be applied to actions

throttle :: RateLimit -> IO a -> IO a Source #

Delay the given action according to the RateLimit.

maxConcurrentTasks :: MonadSTM m => Int -> m RateLimit Source #

Limits concurrency to exactly N tasks. If N tasks are already running, the next one needs to wait.

tokenBucket Source #

Arguments

:: MonadIO m 
=> Coordinator 
-> Duration

Specify the rate as a Duration: fromSeconds (1 / X) for X tasks per second

-> Int

Allowed burst tasks: X burst tasks means that X tasks can start without waiting

-> m RateLimit 

Limits concurrency to a specific rate with the tocket bucket strategy.