| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
LibP2P.Yamux.Types
Description
Shared types for Yamux session management.
Types follow the HashiCorp yamux spec.md. SessionRole determines stream ID parity, StreamState tracks the stream lifecycle state machine, and YamuxSession/YamuxStream hold per-session/per-stream mutable state via STM.
Synopsis
- data SessionRole
- data StreamState
- data YamuxError
- data YamuxStream = YamuxStream {
- ysStreamId :: !Word32
- ysState :: !(TVar StreamState)
- ysSendWindow :: !(TVar Word32)
- ysRecvWindow :: !(TVar Word32)
- ysRecvBuf :: !(TQueue ByteString)
- ysSendNotify :: !(TMVar ())
- ysSession :: !YamuxSession
- data YamuxSession = YamuxSession {
- ysessRole :: !SessionRole
- ysessNextStreamId :: !(TVar Word32)
- ysessStreams :: !(TVar (Map Word32 YamuxStream))
- ysessAcceptCh :: !(TBQueue YamuxStream)
- ysessSendCh :: !(TQueue (YamuxHeader, ByteString))
- ysessShutdown :: !(TVar Bool)
- ysessRemoteGoAway :: !(TVar (Maybe GoAwayCode))
- ysessPings :: !(TVar (Map Word32 PingWaiter))
- ysessNextPingId :: !(TVar Word32)
- ysessWrite :: !(ByteString -> IO ())
- ysessRead :: !(Int -> IO ByteString)
- type PingWaiter = TMVar (Either YamuxError ())
Documentation
data SessionRole Source #
SessionRole determines stream ID parity (spec.md §Stream Identification). Client uses odd IDs (1, 3, 5, ...), Server uses even IDs (2, 4, 6, ...).
Constructors
| RoleClient | |
| RoleServer |
Instances
| Show SessionRole Source # | |
Defined in LibP2P.Yamux.Types Methods showsPrec :: Int -> SessionRole -> ShowS # show :: SessionRole -> String # showList :: [SessionRole] -> ShowS # | |
| Eq SessionRole Source # | |
Defined in LibP2P.Yamux.Types | |
data StreamState Source #
Stream state machine (spec.md §Stream OpenCloseReset). States map to the spec's lifecycle: SYN sentreceived -> Established -> FIN sentreceived -> Closed
Constructors
| StreamSYNSent | SYN sent, awaiting ACK (initiator) |
| StreamSYNReceived | SYN received, awaiting local ACK (responder) |
| StreamEstablished | Both SYN/ACK exchanged, data flows |
| StreamLocalClose | Local FIN sent (half-closed) |
| StreamRemoteClose | Remote FIN received (half-closed) |
| StreamClosed | Both FIN'd |
| StreamReset | RST sent or received |
Instances
| Show StreamState Source # | |
Defined in LibP2P.Yamux.Types Methods showsPrec :: Int -> StreamState -> ShowS # show :: StreamState -> String # showList :: [StreamState] -> ShowS # | |
| Eq StreamState Source # | |
Defined in LibP2P.Yamux.Types | |
data YamuxError Source #
Errors map to spec-defined conditions.
Constructors
| YamuxProtocolError !String | Spec violation (e.g., invalid version, unknown frame type) |
| YamuxStreamClosed | Write/read on closed stream |
| YamuxStreamReset | RST received |
| YamuxSessionShutdown | GoAway received or session closed |
| YamuxGoAway !GoAwayCode | Remote sent GoAway with specific code |
Instances
| Show YamuxError Source # | |
Defined in LibP2P.Yamux.Types Methods showsPrec :: Int -> YamuxError -> ShowS # show :: YamuxError -> String # showList :: [YamuxError] -> ShowS # | |
| Eq YamuxError Source # | |
Defined in LibP2P.Yamux.Types | |
data YamuxStream Source #
Per-stream state (spec.md §Flow Control: per-stream windows only).
Constructors
| YamuxStream | |
Fields
| |
data YamuxSession Source #
Session state.
Constructors
| YamuxSession | |
Fields
| |
type PingWaiter = TMVar (Either YamuxError ()) Source #
Result delivered to a pending ping waiter: Right on a matching ACK, Left when the session dies before the ACK arrives.