Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ConnectionTable (m :: Type -> Type) addr
- data ConnectionTableRef
- data ConnectionDirection
- data ValencyCounter (m :: Type -> Type)
- newConnectionTableSTM :: forall (m :: Type -> Type) addr. MonadSTM m => STM m (ConnectionTable m addr)
- newConnectionTable :: MonadSTM m => m (ConnectionTable m addr)
- refConnectionSTM :: forall (m :: Type -> Type) addr. (MonadSTM m, Ord addr) => ConnectionTable m addr -> addr -> ConnectionDirection -> ValencyCounter m -> STM m ConnectionTableRef
- refConnection :: (MonadSTM m, Ord addr) => ConnectionTable m addr -> addr -> ConnectionDirection -> ValencyCounter m -> m ConnectionTableRef
- addConnection :: forall (m :: Type -> Type) addr. (MonadSTM m, Ord addr) => ConnectionTable m addr -> addr -> addr -> ConnectionDirection -> Maybe (ValencyCounter m) -> STM m ()
- removeConnectionSTM :: forall (m :: Type -> Type) addr. (MonadSTM m, Ord addr) => ConnectionTable m addr -> addr -> addr -> ConnectionDirection -> STM m ()
- removeConnection :: (MonadSTM m, Ord addr) => ConnectionTable m addr -> addr -> addr -> ConnectionDirection -> m ()
- newValencyCounter :: forall (m :: Type -> Type) addr. MonadSTM m => ConnectionTable m addr -> Int -> STM m (ValencyCounter m)
- addValencyCounter :: forall (m :: Type -> Type). MonadSTM m => ValencyCounter m -> STM m ()
- remValencyCounter :: forall (m :: Type -> Type). MonadSTM m => ValencyCounter m -> STM m ()
- waitValencyCounter :: forall (m :: Type -> Type). MonadSTM m => ValencyCounter m -> STM m ()
- readValencyCounter :: forall (m :: Type -> Type). MonadSTM m => ValencyCounter m -> STM m Int
Documentation
data ConnectionTable (m :: Type -> Type) addr Source #
data ConnectionTableRef Source #
ConnectionTableCreate | No connection to peer exists, attempt to create one. |
ConnectionTableExist | A connection to the peer existed, either from another subscriber or the peer opened one towards us. |
ConnectionTableDuplicate | This subscriber already has counted a connection to this peer. It must try another target. |
Instances
Show ConnectionTableRef Source # | |
Defined in Ouroboros.Network.Server.ConnectionTable showsPrec :: Int -> ConnectionTableRef -> ShowS # show :: ConnectionTableRef -> String # showList :: [ConnectionTableRef] -> ShowS # |
data ConnectionDirection Source #
Tracks connection direction. Used to differentiate between outbound connections we are required to create and inbound connections from the same peer.
Instances
Show ConnectionDirection Source # | |
Defined in Ouroboros.Network.Server.ConnectionTable showsPrec :: Int -> ConnectionDirection -> ShowS # show :: ConnectionDirection -> String # showList :: [ConnectionDirection] -> ShowS # | |
Eq ConnectionDirection Source # | |
Defined in Ouroboros.Network.Server.ConnectionTable (==) :: ConnectionDirection -> ConnectionDirection -> Bool # (/=) :: ConnectionDirection -> ConnectionDirection -> Bool # | |
Ord ConnectionDirection Source # | |
Defined in Ouroboros.Network.Server.ConnectionTable compare :: ConnectionDirection -> ConnectionDirection -> Ordering # (<) :: ConnectionDirection -> ConnectionDirection -> Bool # (<=) :: ConnectionDirection -> ConnectionDirection -> Bool # (>) :: ConnectionDirection -> ConnectionDirection -> Bool # (>=) :: ConnectionDirection -> ConnectionDirection -> Bool # max :: ConnectionDirection -> ConnectionDirection -> ConnectionDirection # min :: ConnectionDirection -> ConnectionDirection -> ConnectionDirection # |
data ValencyCounter (m :: Type -> Type) Source #
ValencyCounter represents how many active connections we have towards a given peer. It starts out with a positive value representing a desired number of connections for a specific subscription worker. It can become negative, for example if a peer opens multiple connections to us. The vcId is unique per ConnectionTable and ensures that we won't count the same connection twice.
Instances
Eq (ValencyCounter m) Source # | |
Defined in Ouroboros.Network.Server.ConnectionTable (==) :: ValencyCounter m -> ValencyCounter m -> Bool # (/=) :: ValencyCounter m -> ValencyCounter m -> Bool # | |
Ord (ValencyCounter m) Source # | |
Defined in Ouroboros.Network.Server.ConnectionTable compare :: ValencyCounter m -> ValencyCounter m -> Ordering # (<) :: ValencyCounter m -> ValencyCounter m -> Bool # (<=) :: ValencyCounter m -> ValencyCounter m -> Bool # (>) :: ValencyCounter m -> ValencyCounter m -> Bool # (>=) :: ValencyCounter m -> ValencyCounter m -> Bool # max :: ValencyCounter m -> ValencyCounter m -> ValencyCounter m # min :: ValencyCounter m -> ValencyCounter m -> ValencyCounter m # |
newConnectionTableSTM :: forall (m :: Type -> Type) addr. MonadSTM m => STM m (ConnectionTable m addr) Source #
Create a new ConnectionTable.
newConnectionTable :: MonadSTM m => m (ConnectionTable m addr) Source #
refConnectionSTM :: forall (m :: Type -> Type) addr. (MonadSTM m, Ord addr) => ConnectionTable m addr -> addr -> ConnectionDirection -> ValencyCounter m -> STM m ConnectionTableRef Source #
Try to see if it is possible to reference an existing connection rather than creating a new one to the provied peer.
refConnection :: (MonadSTM m, Ord addr) => ConnectionTable m addr -> addr -> ConnectionDirection -> ValencyCounter m -> m ConnectionTableRef Source #
:: forall (m :: Type -> Type) addr. (MonadSTM m, Ord addr) | |
=> ConnectionTable m addr | |
-> addr | |
-> addr | |
-> ConnectionDirection | |
-> Maybe (ValencyCounter m) | Optional ValencyCounter, used by subscription worker and set to Nothing when called by a local server. |
-> STM m () |
Insert a new connection into the ConnectionTable.
removeConnectionSTM :: forall (m :: Type -> Type) addr. (MonadSTM m, Ord addr) => ConnectionTable m addr -> addr -> addr -> ConnectionDirection -> STM m () Source #
Remove a Connection.
removeConnection :: (MonadSTM m, Ord addr) => ConnectionTable m addr -> addr -> addr -> ConnectionDirection -> m () Source #
:: forall (m :: Type -> Type) addr. MonadSTM m | |
=> ConnectionTable m addr | |
-> Int | Desired valency, that is number of connections a subscription worker will attempt to maintain. |
-> STM m (ValencyCounter m) |
Create a new ValencyCounter
addValencyCounter :: forall (m :: Type -> Type). MonadSTM m => ValencyCounter m -> STM m () Source #
Add a connection.
remValencyCounter :: forall (m :: Type -> Type). MonadSTM m => ValencyCounter m -> STM m () Source #
Remove a connection.
waitValencyCounter :: forall (m :: Type -> Type). MonadSTM m => ValencyCounter m -> STM m () Source #
Wait until ValencyCounter becomes positive, used for detecting when we can create new connections.
readValencyCounter :: forall (m :: Type -> Type). MonadSTM m => ValencyCounter m -> STM m Int Source #
Returns current ValencyCounter value, represent the number of additional connections that can be created. May be negative.