-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Library to control network protocols -- -- Common parts to control network protocols @package network-control @version 0.1.2 -- | Common parts to control network protocols. This library assumes that -- Int is 64bit. module Network.Control -- | Default max streams. (64) defaultMaxStreams :: Int -- | Default max data of a stream. (256K bytes) defaultMaxStreamData :: Int -- | Default max data of a connection. -- -- By default, this is set to defaultMaxStreams * -- defaultMaxStreamData. This ensures that streams that are not -- currently handled cannot exhaust the connection window. -- -- If you use a smaller connection window size, you must ensure -- that if you are handling fewer concurrent streams than allowed by -- defaultMaxStreams, that the unhandled streams cannot exhaust -- the connection window, or risk the entire system deadlocking. defaultMaxData :: Int -- | Flow for sending -- --
--   -------------------------------------->
--          ^           ^
--       txfSent    txfLimit
--   
--          |-----------| The size which this node can send
--          txWindowSize
--   
data TxFlow TxFlow :: Int -> Int -> TxFlow -- | The total size of sent data. [txfSent] :: TxFlow -> Int -- | The total size of data which can be sent. [txfLimit] :: TxFlow -> Int -- | Creating TX flow with a receive buffer size. newTxFlow :: WindowSize -> TxFlow -- | txfLimit - txfSent. txWindowSize :: TxFlow -> WindowSize -- | Window size. type WindowSize = Int -- | Flow for receiving. -- --
--                   rxfBufSize
--          |------------------------|
--   -------------------------------------->
--          ^            ^           ^
--     rxfConsumed   rxfReceived  rxfLimit
--   
--                       |-----------| The size which the peer can send
--                        rxWindowSize
--   
data RxFlow RxFlow :: Int -> Int -> Int -> Int -> RxFlow -- | Receive buffer size. [rxfBufSize] :: RxFlow -> Int -- | The total size which the application is consumed. [rxfConsumed] :: RxFlow -> Int -- | The total already-received size. [rxfReceived] :: RxFlow -> Int -- | The total size which can be recived. [rxfLimit] :: RxFlow -> Int -- | Creating RX flow with an initial window size. newRxFlow :: WindowSize -> RxFlow -- | rxfLimit - rxfReceived. rxWindowSize :: RxFlow -> WindowSize -- | The representation of window size update. data FlowControlType -- | HTTP/2 style FCTWindowUpdate :: FlowControlType -- | QUIC style FCTMaxData :: FlowControlType -- | When an application consumed received data, this function should be -- called to update rxfConsumed. If the available buffer size is -- less than the half of the total buffer size AND window size update is -- greater than 1/8 of the the total buffer size, the representation of -- the window size update is returned. -- --
--   Example:
--   
--                   rxfBufSize
--          |------------------------|
--   -------------------------------------->
--          ^            ^           ^
--     rxfConsumed   rxfReceived  rxfLimit
--                       |01234567890|
--   
--   In the case where the window update should be informed to the peer,
--   rxfConsumed and rxfLimit move to the right. The difference
--   of old and new rxfLimit is window update.
--   
--                     rxfBufSize
--            |------------------------|
--   -------------------------------------->
--            ^          ^             ^
--       rxfConsumed rxfReceived    rxfLimit
--                       |0123456789012| : window glows
--   
--   Otherwise, only rxfConsumed moves to the right.
--   
--                   rxfBufSize
--          |------------------------|
--   -------------------------------------->
--            ^          ^           ^
--       rxfConsumed rxfReceived  rxfLimit
--                       |01234567890| : window stays
--   
maybeOpenRxWindow :: Int -> FlowControlType -> RxFlow -> (RxFlow, Maybe Int) -- | Checking if received data is acceptable against the current window. checkRxLimit :: Int -> RxFlow -> (RxFlow, Bool) -- | Sized cache based on least recently used. data LRUCache k v -- | Empty LRUCache. empty :: Int -> LRUCache k v -- | Inserting. insert :: Ord k => k -> v -> LRUCache k v -> LRUCache k v -- | Deleting. delete :: Ord k => k -> LRUCache k v -> LRUCache k v -- | Looking up. lookup :: Ord k => k -> LRUCache k v -> Maybe v -- | Type for rating. data Rate -- | Creating a new Rate. newRate :: IO Rate -- | Getting the current rate. If one or more seconds have passed since the -- previous call, the counter is re-initialized with 1 and it is -- returned. Otherwise, incremented counter number is returned. getRate :: Rate -> IO Int -- | Getting the current rate. If one or more seconds have passed since the -- previous call, the counter is re-initialized with the second argument -- and it is returned. Otherwise, increased counter number is returned. addRate :: Rate -> Int -> IO Int