Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ouroboros.Network.ErrorPolicy
Contents
Description
Error policies, and integration with SuspendDecision
-semigroup action on
PeerState
.
Synopsis
- data ErrorPolicies = ErrorPolicies {}
- nullErrorPolicies ∷ ErrorPolicies
- data ErrorPolicy where
- ErrorPolicy ∷ ∀ e. Exception e ⇒ (e → Maybe (SuspendDecision DiffTime)) → ErrorPolicy
- evalErrorPolicy ∷ ∀ e. Exception e ⇒ e → ErrorPolicy → Maybe (SuspendDecision DiffTime)
- evalErrorPolicies ∷ ∀ e. Exception e ⇒ e → [ErrorPolicy] → Maybe (SuspendDecision DiffTime)
- type CompleteApplication m s addr r = Result addr r → s → STM m (CompleteApplicationResult m addr s)
- data CompleteApplicationResult m addr s = CompleteApplicationResult {
- carState ∷ !s
- carThreads ∷ Set (Async m ())
- carTrace ∷ Maybe (WithAddr addr ErrorPolicyTrace)
- data Result addr r where
- ApplicationResult ∷ !Time → !addr → !r → Result addr r
- Connected ∷ !Time → !addr → Result addr r
- ConnectionError ∷ Exception e ⇒ !Time → !addr → !e → Result addr r
- ApplicationError ∷ Exception e ⇒ !Time → !addr → !e → Result addr r
- completeApplicationTx ∷ ∀ m 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 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.
Constructors
ErrorPolicies | |
Fields
|
Instances
Semigroup ErrorPolicies Source # | |
Defined in Ouroboros.Network.ErrorPolicy Methods (<>) ∷ ErrorPolicies → ErrorPolicies → ErrorPolicies Source # sconcat ∷ NonEmpty ErrorPolicies → ErrorPolicies Source # stimes ∷ Integral b ⇒ b → ErrorPolicies → ErrorPolicies Source # |
data ErrorPolicy where Source #
Constructors
ErrorPolicy | |
Fields
|
Instances
Show ErrorPolicy Source # | |
Defined in Ouroboros.Network.ErrorPolicy |
evalErrorPolicy ∷ ∀ e. Exception e ⇒ e → ErrorPolicy → Maybe (SuspendDecision DiffTime) Source #
evalErrorPolicies ∷ ∀ e. 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 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 addr s Source #
Constructors
CompleteApplicationResult | |
Fields
|
Instances
Functor (CompleteApplicationResult m addr) Source # | |
Defined in Ouroboros.Network.ErrorPolicy Methods fmap ∷ (a → b) → CompleteApplicationResult m addr a → CompleteApplicationResult m addr b Source # (<$) ∷ a → CompleteApplicationResult m addr b → CompleteApplicationResult m addr a Source # |
data Result addr r where Source #
Result of the connection thread. It's either result of an application, or an exception thrown by it.
Constructors
ApplicationResult ∷ !Time → !addr → !r → Result addr r | |
Connected ∷ !Time → !addr → Result addr r | |
ConnectionError ∷ Exception e ⇒ !Time → !addr → !e → Result addr r | |
ApplicationError ∷ Exception e ⇒ !Time → !addr → !e → Result addr r |
completeApplicationTx ∷ ∀ m 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
Constructors
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 |
traceErrorPolicy ∷ Either (ConnectionOrApplicationExceptionTrace SomeException) r → SuspendDecision DiffTime → Maybe ErrorPolicyTrace Source #
Re-exports of PeerState
data PeerStates m 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 Methods (==) ∷ PeerStates IO addr → PeerStates IO addr → Bool Source # (/=) ∷ PeerStates IO addr → PeerStates IO addr → Bool Source # |
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.
Constructors
SuspendPeer !t !t | peer is suspend; The first |
SuspendConsumer !t | suspend local consumer / initiator side until |
Throw | throw an error from the main thread. |