network-control-0.0.1: Library to control network protocols
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.Control

Description

Common parts to control network protocols.

Synopsis

Flow control for sending

data TxFlow Source #

Flow for sending

Constructors

TxFlow 

Fields

Instances

Instances details
Show TxFlow Source # 
Instance details

Defined in Network.Control.Flow

newTxFlow :: WindowSize -> TxFlow Source #

Creating TX flow with an initial window size.

type WindowSize = Int Source #

Window size.

Flow control for receiving

data RxFlow Source #

Flow for receiving

Constructors

RxFlow 

Instances

Instances details
Show RxFlow Source # 
Instance details

Defined in Network.Control.Flow

newRxFlow :: WindowSize -> RxFlow Source #

Creating RX flow with an initial window size.

data FlowControlType Source #

The representation of window size update.

Constructors

FCTWindowUpdate

HTTP/2 style

FCTMaxData

QUIC style

maybeOpenRxWindow Source #

Arguments

:: Int

The consumed size.

-> FlowControlType 
-> RxFlow 
-> (RxFlow, Maybe Int)

Just if the size should be informed to the peer.

When an application consumed received data, this function should be called to update rxfConsumed. If the window size is less than the half of the initial window. the representation of window size update is returned.

checkRxLimit Source #

Arguments

:: Int

The size of received data.

-> RxFlow 
-> (RxFlow, Bool)

Acceptable if True.

Checking if received data is acceptable against the current window.

LRU cache

data LRUCache k v Source #

Sized cache based on least recently used.

empty Source #

Arguments

:: Int

The size of LRUCache.

-> LRUCache k v 

Empty LRUCache.

insert :: Ord k => k -> v -> LRUCache k v -> LRUCache k v Source #

Inserting.

delete :: Ord k => k -> LRUCache k v -> LRUCache k v Source #

Deleting.

lookup :: Ord k => k -> LRUCache k v -> Maybe v Source #

Looking up.

Rate control

data Rate Source #

Type for rating.

newRate :: IO Rate Source #

Creating a new Rate.

getRate :: Rate -> IO Int Source #

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.

addRate :: Rate -> Int -> IO Int Source #

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.