Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Address = Address SockAddr
- extractAddress :: Request -> Either Response Address
- data CacheState a
- data CacheResult a
- data Throttle a = Throttle {}
- data ThrottleSettings = ThrottleSettings {}
- defaultThrottleSettings :: TimeSpec -> ThrottleSettings
- initThrottler :: ThrottleSettings -> IO (Throttle Address)
- initCustomThrottler :: ThrottleSettings -> (Request -> Either Response a) -> IO (Throttle a)
- retrieveCache :: (Eq a, Hashable a) => Throttle a -> TimeSpec -> a -> STM (CacheResult TokenBucket)
- processCacheResult :: (Eq a, Hashable a) => Throttle a -> a -> CacheResult TokenBucket -> IO TokenBucket
- retrieveOrInitializeBucket :: (Eq a, Hashable a) => Throttle a -> a -> IO TokenBucket
- throttleRequest :: (Eq a, Hashable a) => Throttle a -> a -> IO Word64
- throttle :: (Eq a, Hashable a) => Throttle a -> Application -> Application
Documentation
data CacheState a Source #
Instances
Show (CacheState a) Source # | |
Defined in Network.Wai.Middleware.Throttle.Internal showsPrec :: Int -> CacheState a -> ShowS # show :: CacheState a -> String # showList :: [CacheState a] -> ShowS # |
data CacheResult a Source #
Instances
Show (CacheResult a) Source # | |
Defined in Network.Wai.Middleware.Throttle.Internal showsPrec :: Int -> CacheResult a -> ShowS # show :: CacheResult a -> String # showList :: [CacheResult a] -> ShowS # |
A throttle for a hashable key type. Initialize using initThrottler
with defaultThrottleSettings
.
Throttle | |
|
data ThrottleSettings Source #
Throttle settings for controlling token bucket algorithm and cache expiration.
ThrottleSettings | |
|
defaultThrottleSettings :: TimeSpec -> ThrottleSettings Source #
Default throttle settings.
initThrottler :: ThrottleSettings -> IO (Throttle Address) Source #
initCustomThrottler :: ThrottleSettings -> (Request -> Either Response a) -> IO (Throttle a) Source #
Initialize a throttle using settings and a way to extract the key from the request.
retrieveCache :: (Eq a, Hashable a) => Throttle a -> TimeSpec -> a -> STM (CacheResult TokenBucket) Source #
Internal use only. Retrieve a token bucket from the cache.
processCacheResult :: (Eq a, Hashable a) => Throttle a -> a -> CacheResult TokenBucket -> IO TokenBucket Source #
Internal use only. Create a token bucket if it wasn't in the cache.
retrieveOrInitializeBucket :: (Eq a, Hashable a) => Throttle a -> a -> IO TokenBucket Source #
Internal use only. Retrieve or initialize a token bucket depending on if it was found in the cache.
throttleRequest :: (Eq a, Hashable a) => Throttle a -> a -> IO Word64 Source #
Internal use only. Throttle a request by the throttle key.
throttle :: (Eq a, Hashable a) => Throttle a -> Application -> Application Source #
Run the throttling middleware given a throttle that has been initialized.