| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
LibP2P.Switch.Connection
Description
Connection lifecycle for the Switch.
Provides the single teardown path for upgraded connections and a
resource-accounted outbound stream opener. Teardown fires from the
stream accept loop exit (remote disconnect or session death), from
explicit closeConnection calls, and from switchClose via
closeAllConnections.
Synopsis
- closeConnection :: Switch -> Connection -> IO ()
- closeAllConnections :: Switch -> IO ()
- newStream :: Switch -> Connection -> IO (Either ResourceError StreamIO)
Documentation
closeConnection :: Switch -> Connection -> IO () Source #
Tear down a connection: remove it from the pool, release its resource reservation, publish a Disconnected event, and close the muxer session together with the underlying transport.
Idempotent: the state transition to ConnClosed is atomic, so concurrent calls (accept loop exit, explicit close, switchClose) perform the teardown exactly once.
closeAllConnections :: Switch -> IO () Source #
Tear down every pooled connection (used by switchClose).
newStream :: Switch -> Connection -> IO (Either ResourceError StreamIO) Source #
Open an outbound stream on a connection, reserving a stream slot against the peer's resource scope. The slot is released when the returned stream is closed (exactly once, even on double close).