Safe Haskell | None |
---|---|
Language | Haskell2010 |
The implementation of connection manager.
The module should be imported qualified.
Synopsis
- data Arguments handlerTrace socket peerAddr handle handleError versionNumber versionData (m :: Type -> Type) = Arguments {
- tracer :: Tracer m (Trace peerAddr handlerTrace)
- trTracer :: Tracer m (TransitionTrace peerAddr (ConnectionState peerAddr handle handleError versionNumber m))
- muxTracer :: Tracer m (WithBearer (ConnectionId peerAddr) Trace)
- ipv4Address :: Maybe peerAddr
- ipv6Address :: Maybe peerAddr
- addressType :: peerAddr -> Maybe AddressType
- snocket :: Snocket m socket peerAddr
- makeBearer :: MakeBearer m socket
- configureSocket :: socket -> Maybe peerAddr -> m ()
- timeWaitTimeout :: DiffTime
- outboundIdleTimeout :: DiffTime
- connectionDataFlow :: versionData -> DataFlow
- prunePolicy :: PrunePolicy peerAddr
- stdGen :: StdGen
- connectionsLimits :: AcceptedConnectionsLimit
- data Trace peerAddr handlerTrace
- = TrIncludeConnection Provenance peerAddr
- | TrReleaseConnection Provenance peerAddr
- | TrConnect (Maybe peerAddr) peerAddr
- | TrConnectError (Maybe peerAddr) peerAddr SomeException
- | TrTerminatingConnection Provenance (ConnectionId peerAddr)
- | TrTerminatedConnection Provenance peerAddr
- | TrConnectionHandler (ConnectionId peerAddr) handlerTrace
- | TrShutdown
- | TrConnectionExists Provenance peerAddr AbstractState
- | TrForbiddenConnection (ConnectionId peerAddr)
- | TrConnectionFailure (ConnectionId peerAddr)
- | TrConnectionNotFound Provenance peerAddr
- | TrForbiddenOperation peerAddr AbstractState
- | TrPruneConnections (Set peerAddr) Int (Set peerAddr)
- | TrConnectionCleanup (ConnectionId peerAddr)
- | TrConnectionTimeWait (ConnectionId peerAddr)
- | TrConnectionTimeWaitDone (ConnectionId peerAddr)
- | TrConnectionManagerCounters ConnectionManagerCounters
- | TrState (Map peerAddr AbstractState)
- | TrUnexpectedlyFalseAssertion (AssertionLocation peerAddr)
- with :: forall (muxMode :: Mode) peerAddr socket handlerTrace handle handleError version versionData m a. (Alternative (STM m), MonadLabelledSTM m, MonadTraceSTM m, MonadFork m, MonadAsync m, MonadDelay m, MonadEvaluate m, MonadFix m, MonadMask m, MonadThrow (STM m), MonadTimer m, Ord peerAddr, Show peerAddr, Typeable peerAddr) => Arguments handlerTrace socket peerAddr handle handleError version versionData m -> ConnectionHandler muxMode handlerTrace socket peerAddr handle handleError (version, versionData) m -> (handleError -> HandleErrorType) -> InResponderMode muxMode (InformationChannel (NewConnectionInfo peerAddr handle) m) -> (ConnectionManager muxMode socket peerAddr handle handleError m -> m a) -> m a
- defaultTimeWaitTimeout :: DiffTime
- defaultProtocolIdleTimeout :: DiffTime
- defaultResetTimeout :: DiffTime
- data ConnectionState peerAddr handle handleError version (m :: Type -> Type)
- = ReservedOutboundState
- | UnnegotiatedState !Provenance !(ConnectionId peerAddr) (Async m ())
- | OutboundUniState !(ConnectionId peerAddr) !(Async m ()) !handle
- | OutboundDupState !(ConnectionId peerAddr) !(Async m ()) !handle !TimeoutExpired
- | OutboundIdleState !(ConnectionId peerAddr) !(Async m ()) !handle !DataFlow
- | InboundIdleState !(ConnectionId peerAddr) !(Async m ()) !handle !DataFlow
- | InboundState !(ConnectionId peerAddr) !(Async m ()) !handle !DataFlow
- | DuplexState !(ConnectionId peerAddr) !(Async m ()) !handle
- | TerminatingState !(ConnectionId peerAddr) !(Async m ()) !(Maybe handleError)
- | TerminatedState !(Maybe handleError)
- abstractState :: forall muxMode peerAddr m a (b :: Type -> Type). MaybeUnknown (ConnectionState muxMode peerAddr m a b) -> AbstractState
Documentation
data Arguments handlerTrace socket peerAddr handle handleError versionNumber versionData (m :: Type -> Type) Source #
Arguments for a ConnectionManager
which are independent of MuxMode
.
Arguments | |
|
data Trace peerAddr handlerTrace Source #
ConnectionManagerTrace
contains a hole for a trace of single connection
which is filled with ConnectionHandlerTrace
.
Instances
:: forall (muxMode :: Mode) peerAddr socket handlerTrace handle handleError version versionData m a. (Alternative (STM m), MonadLabelledSTM m, MonadTraceSTM m, MonadFork m, MonadAsync m, MonadDelay m, MonadEvaluate m, MonadFix m, MonadMask m, MonadThrow (STM m), MonadTimer m, Ord peerAddr, Show peerAddr, Typeable peerAddr) | |
=> Arguments handlerTrace socket peerAddr handle handleError version versionData m | |
-> ConnectionHandler muxMode handlerTrace socket peerAddr handle handleError (version, versionData) m | Callback which runs in a thread dedicated for a given connection. |
-> (handleError -> HandleErrorType) | classify |
-> InResponderMode muxMode (InformationChannel (NewConnectionInfo peerAddr handle) m) | On outbound duplex connections we need to notify the server about a new connection. |
-> (ConnectionManager muxMode socket peerAddr handle handleError m -> m a) | Continuation which receives the |
-> m a |
Entry point for using the connection manager. This is a classic with
style
combinator, which cleans resources on exit of the callback (whether cleanly
or through an exception).
Including a connection (either inbound or outbound) is an idempotent operation on connection manager state. The connection manager will always return the handle that was first to be included in its state.
Once an inbound connection is passed to the ConnectionManager
, the manager
is responsible for the resource.
defaultTimeWaitTimeout :: DiffTime Source #
The default value for timeWaitTimeout
.
defaultProtocolIdleTimeout :: DiffTime Source #
Inactivity timeout. It configures how long to wait since the local side demoted remote peer to cold, before closing the connection.
data ConnectionState peerAddr handle handleError version (m :: Type -> Type) Source #
State of a connection.
ReservedOutboundState | Each outbound connections starts in this state. |
UnnegotiatedState !Provenance !(ConnectionId peerAddr) (Async m ()) | Each inbound connection starts in this state, outbound connection
reach this state once note: the async handle is lazy, because it's passed with |
OutboundUniState !(ConnectionId peerAddr) !(Async m ()) !handle |
|
OutboundDupState !(ConnectionId peerAddr) !(Async m ()) !handle !TimeoutExpired | Either |
OutboundIdleState !(ConnectionId peerAddr) !(Async m ()) !handle !DataFlow | Before connection is reset it is put in |
InboundIdleState !(ConnectionId peerAddr) !(Async m ()) !handle !DataFlow | |
InboundState !(ConnectionId peerAddr) !(Async m ()) !handle !DataFlow | |
DuplexState !(ConnectionId peerAddr) !(Async m ()) !handle | |
TerminatingState !(ConnectionId peerAddr) !(Async m ()) !(Maybe handleError) | |
TerminatedState !(Maybe handleError) |
Instances
(Show peerAddr, Show handleError, MonadAsync m) => Show (ConnectionState peerAddr handle handleError version m) Source # | |
Defined in Ouroboros.Network.ConnectionManager.Core showsPrec :: Int -> ConnectionState peerAddr handle handleError version m -> ShowS # show :: ConnectionState peerAddr handle handleError version m -> String # showList :: [ConnectionState peerAddr handle handleError version m] -> ShowS # |
abstractState :: forall muxMode peerAddr m a (b :: Type -> Type). MaybeUnknown (ConnectionState muxMode peerAddr m a b) -> AbstractState Source #