Safe Haskell | None |
---|---|
Language | Haskell2010 |
Error policies, and integration with SuspendDecision
-semigroup action on
PeerState
.
Synopsis
- data ErrorPolicies = ErrorPolicies {}
- nullErrorPolicies :: ErrorPolicies
- data ErrorPolicy where
- ErrorPolicy :: forall e. Exception e => (e -> Maybe (SuspendDecision DiffTime)) -> ErrorPolicy
- evalErrorPolicy :: Exception e => e -> ErrorPolicy -> Maybe (SuspendDecision DiffTime)
- evalErrorPolicies :: Exception e => e -> [ErrorPolicy] -> Maybe (SuspendDecision DiffTime)
- type CompleteApplication (m :: Type -> Type) s addr r = Result addr r -> s -> STM m (CompleteApplicationResult m addr s)
- data CompleteApplicationResult (m :: Type -> Type) addr s = CompleteApplicationResult {
- carState :: !s
- carThreads :: Set (Async m ())
- carTrace :: Maybe (WithAddr addr ErrorPolicyTrace)
- data Result addr r where
- ApplicationResult :: forall addr r. !Time -> !addr -> !r -> Result addr r
- Connected :: forall addr r. !Time -> !addr -> Result addr r
- ConnectionError :: forall e addr r. Exception e => !Time -> !addr -> !e -> Result addr r
- ApplicationError :: forall e addr r. Exception e => !Time -> !addr -> !e -> Result addr r
- completeApplicationTx :: forall (m :: Type -> Type) addr a. (MonadAsync m, Ord addr, Ord (Async m ())) => ErrorPolicies -> CompleteApplication m (PeerStates m addr) addr a
- data ErrorPolicyTrace
- = ErrorPolicySuspendPeer (Maybe (ConnectionOrApplicationExceptionTrace SomeException)) DiffTime DiffTime
- | ErrorPolicySuspendConsumer (Maybe (ConnectionOrApplicationExceptionTrace SomeException)) DiffTime
- | ErrorPolicyLocalNodeError (ConnectionOrApplicationExceptionTrace SomeException)
- | ErrorPolicyResumePeer
- | ErrorPolicyKeepSuspended
- | ErrorPolicyResumeConsumer
- | ErrorPolicyResumeProducer
- | ErrorPolicyUnhandledApplicationException SomeException
- | ErrorPolicyUnhandledConnectionException SomeException
- | ErrorPolicyAcceptException IOException
- traceErrorPolicy :: Either (ConnectionOrApplicationExceptionTrace SomeException) r -> SuspendDecision DiffTime -> Maybe ErrorPolicyTrace
- data WithAddr addr a = WithAddr {}
- data PeerStates (m :: Type -> Type) addr
- data SuspendDecision t
- = SuspendPeer !t !t
- | SuspendConsumer !t
- | Throw
Documentation
data ErrorPolicies Source #
List of error policies for exception handling and a policy for handing application return values.
ErrorPolicies | |
|
Instances
Semigroup ErrorPolicies Source # | |
Defined in Ouroboros.Network.ErrorPolicy (<>) :: ErrorPolicies -> ErrorPolicies -> ErrorPolicies # sconcat :: NonEmpty ErrorPolicies -> ErrorPolicies # stimes :: Integral b => b -> ErrorPolicies -> ErrorPolicies # |
data ErrorPolicy where Source #
ErrorPolicy | |
|
Instances
Show ErrorPolicy Source # | |
Defined in Ouroboros.Network.ErrorPolicy showsPrec :: Int -> ErrorPolicy -> ShowS # show :: ErrorPolicy -> String # showList :: [ErrorPolicy] -> ShowS # |
evalErrorPolicy :: Exception e => e -> ErrorPolicy -> Maybe (SuspendDecision DiffTime) Source #
evalErrorPolicies :: Exception e => e -> [ErrorPolicy] -> Maybe (SuspendDecision DiffTime) Source #
Evaluate a list of ErrorPolicy
s; If none of them applies this function
returns Nothing
, in this case the exception will be traced and not thrown.
type CompleteApplication (m :: Type -> Type) s addr r = Result addr r -> s -> STM m (CompleteApplicationResult m addr s) Source #
Complete a connection, which receive application result (or exception).
data CompleteApplicationResult (m :: Type -> Type) addr s Source #
CompleteApplicationResult | |
|
Instances
Functor (CompleteApplicationResult m addr) Source # | |
Defined in Ouroboros.Network.ErrorPolicy fmap :: (a -> b) -> CompleteApplicationResult m addr a -> CompleteApplicationResult m addr b # (<$) :: a -> CompleteApplicationResult m addr b -> CompleteApplicationResult m addr a # |
data Result addr r where Source #
Result of the connection thread. It's either result of an application, or an exception thrown by it.
ApplicationResult :: forall addr r. !Time -> !addr -> !r -> Result addr r | |
Connected :: forall addr r. !Time -> !addr -> Result addr r | |
ConnectionError :: forall e addr r. Exception e => !Time -> !addr -> !e -> Result addr r | |
ApplicationError :: forall e addr r. Exception e => !Time -> !addr -> !e -> Result addr r |
completeApplicationTx :: forall (m :: Type -> Type) addr a. (MonadAsync m, Ord addr, Ord (Async m ())) => ErrorPolicies -> CompleteApplication m (PeerStates m addr) addr a Source #
CompleteApplication
callback
Traces
data ErrorPolicyTrace Source #
Trace data for error policies
ErrorPolicySuspendPeer (Maybe (ConnectionOrApplicationExceptionTrace SomeException)) DiffTime DiffTime | suspending peer with a given exception until |
ErrorPolicySuspendConsumer (Maybe (ConnectionOrApplicationExceptionTrace SomeException)) DiffTime | suspending consumer until |
ErrorPolicyLocalNodeError (ConnectionOrApplicationExceptionTrace SomeException) | caught a local exception |
ErrorPolicyResumePeer | resume a peer (both consumer and producer) |
ErrorPolicyKeepSuspended | consumer was suspended until producer will resume |
ErrorPolicyResumeConsumer | resume consumer |
ErrorPolicyResumeProducer | resume producer |
ErrorPolicyUnhandledApplicationException SomeException | an application throwed an exception, which was not handled by any
|
ErrorPolicyUnhandledConnectionException SomeException |
|
ErrorPolicyAcceptException IOException |
|
Instances
Show ErrorPolicyTrace Source # | |
Defined in Ouroboros.Network.ErrorPolicy showsPrec :: Int -> ErrorPolicyTrace -> ShowS # show :: ErrorPolicyTrace -> String # showList :: [ErrorPolicyTrace] -> ShowS # |
traceErrorPolicy :: Either (ConnectionOrApplicationExceptionTrace SomeException) r -> SuspendDecision DiffTime -> Maybe ErrorPolicyTrace Source #
Re-exports of PeerState
data PeerStates (m :: Type -> Type) addr Source #
Map from addresses to PeerState
s; it will be be shared in a StrictTVar
.
Abstracting t
is useful for tests, the IO
version will use Time IO
.
Instances
Show addr => Show (PeerStates IO addr) Source # | |
Defined in Ouroboros.Network.Subscription.PeerState | |
Eq addr => Eq (PeerStates IO addr) Source # | |
Defined in Ouroboros.Network.Subscription.PeerState (==) :: PeerStates IO addr -> PeerStates IO addr -> Bool # (/=) :: PeerStates IO addr -> PeerStates IO addr -> Bool # |
data SuspendDecision t Source #
Semigroup of commands which acts on PeerState
. The t
variable might
be initiated to DiffTime
or Time m
.
This semigroup allows to either suspend both consumer and producer or just the consumer part.
SuspendPeer !t !t | peer is suspend; The first |
SuspendConsumer !t | suspend local consumer / initiator side until |
Throw | throw an error from the main thread. |