Safe Haskell | None |
---|---|
Language | Haskell2010 |
Exports functions which implement rate-limiting strategies.
Synopsis
- newtype Strategy = MkStrategy {
- strategyOnRequest :: Request -> IO Bool
- fixedWindow :: Backend key -> Second -> Integer -> (Request -> IO key) -> Strategy
- slidingWindow :: Backend key -> Second -> Integer -> (Request -> IO key) -> Strategy
Documentation
Represents rate limiting strategies.
MkStrategy | |
|
fixedWindow :: Backend key -> Second -> Integer -> (Request -> IO key) -> Strategy Source #
fixedWindow
seconds limit
is a Strategy
which limits the number
of requests made by a client to limit
within a window of seconds
.
slidingWindow :: Backend key -> Second -> Integer -> (Request -> IO key) -> Strategy Source #
slidingWindow
seconds limit
is a Strategy
which limits the number
of requests made by a client to limit
within a sliding window of
seconds
. That is, for every successful request, the window is extended by
seconds
so that a "break" of seconds
is required after limit
-many
requests have been made in a period during which the timeout has never
been exceeded.