Safe Haskell | None |
---|---|
Language | Haskell2010 |
Rethrow policy for MuxConnectionHandler
.
Connection manager has a centralised way of handling exceptions.
RethrowPolicy
is a way to decided whether it is enough to shutdown
connection or the node should shut down itself. Theis mechanism is affected
by the design choices in the mutliplexer.
Whenever a mini-protocol throws an exception, the bearer is closed. There is no way to recover a bidirectional connection if one side failed, in such way that the other end could still re-use it, e.g. if the initiator throws, we cannot just restart it on the same bearer, since there might be unconsumed bytes on the other end.
RethrowPolicy
is supplied to makeMuxConnectionHandler
which creates both
the action that runs on each connection and error handler. Error handler is
attached by the connection manager (see
Core
). This error handler is using
RethrowPolicy
.
This mechanism is enough for both:
- the server implemented in
Server
, PeerStateActions
used by peer-to-peer governor.
Since both start mini-protocols with runMiniProtocol
they can also have
access to the result / exception thrown of a mini-protocol.
PeerStateActions
are only using this to inform the governor that the
peer transitioned to PeerCold
or to deactivate the peer.
Synopsis
- newtype RethrowPolicy = RethrowPolicy {
- runRethrowPolicy :: RethrowPolicy_
- mkRethrowPolicy :: Exception e => (ErrorContext -> e -> ErrorCommand) -> RethrowPolicy
- data ErrorCommand
- data ErrorContext
- muxErrorRethrowPolicy :: RethrowPolicy
- ioErrorRethrowPolicy :: RethrowPolicy
Documentation
newtype RethrowPolicy Source #
RethrowPolicy | |
|
Instances
Monoid RethrowPolicy Source # | |
Defined in Ouroboros.Network.RethrowPolicy mempty :: RethrowPolicy # mappend :: RethrowPolicy -> RethrowPolicy -> RethrowPolicy # mconcat :: [RethrowPolicy] -> RethrowPolicy # | |
Semigroup RethrowPolicy Source # | |
Defined in Ouroboros.Network.RethrowPolicy (<>) :: RethrowPolicy -> RethrowPolicy -> RethrowPolicy # sconcat :: NonEmpty RethrowPolicy -> RethrowPolicy # stimes :: Integral b => b -> RethrowPolicy -> RethrowPolicy # |
mkRethrowPolicy :: Exception e => (ErrorContext -> e -> ErrorCommand) -> RethrowPolicy Source #
Smart constructor for RethrowPolicy
.
data ErrorCommand Source #
ShutdownNode | Shutdown node. |
ShutdownPeer | Shutdown connection with the peer. |
Instances
Monoid ErrorCommand Source # | |
Defined in Ouroboros.Network.RethrowPolicy mempty :: ErrorCommand # mappend :: ErrorCommand -> ErrorCommand -> ErrorCommand # mconcat :: [ErrorCommand] -> ErrorCommand # | |
Semigroup ErrorCommand Source # |
|
Defined in Ouroboros.Network.RethrowPolicy (<>) :: ErrorCommand -> ErrorCommand -> ErrorCommand # sconcat :: NonEmpty ErrorCommand -> ErrorCommand # stimes :: Integral b => b -> ErrorCommand -> ErrorCommand # | |
Show ErrorCommand Source # | |
Defined in Ouroboros.Network.RethrowPolicy showsPrec :: Int -> ErrorCommand -> ShowS # show :: ErrorCommand -> String # showList :: [ErrorCommand] -> ShowS # |
data ErrorContext Source #
Whether an exception happened on outbound or inbound connection.
TODO: It would be more useful to have access to whether the exception
happened on initiator or responder. The easiest way to fix this is make mux
throw the exception together with context. This allows to keep error
handling be done only by the connection manager (rather than by server and
PeerStateActions
).
Instances
Show ErrorContext Source # | |
Defined in Ouroboros.Network.RethrowPolicy showsPrec :: Int -> ErrorContext -> ShowS # show :: ErrorContext -> String # showList :: [ErrorContext] -> ShowS # |