ouroboros-network-framework-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Subscription.Ip

Description

IP subscription worker implentation.

Synopsis

Documentation

data SubscriptionParams a target Source #

ipSubscriptionWorker and dnsSubscriptionWorker parameters

Constructors

SubscriptionParams 

Fields

ipSubscriptionWorker ∷ ∀ a. Snocket IO Socket SockAddr → Tracer IO (WithIPList (SubscriptionTrace SockAddr)) → Tracer IO (WithAddr SockAddr ErrorPolicyTrace) → NetworkMutableState SockAddr → IPSubscriptionParams a → (Socket → IO a) → IO Void Source #

Spawns a subscription worker which will attempt to keep the specified number of connections (Valency) active towards the list of IP addresses given in IPSubscriptionTarget.

subscriptionWorker Source #

Arguments

Snocket IO Socket SockAddr 
→ Tracer IO (SubscriptionTrace SockAddr) 
→ Tracer IO (WithAddr SockAddr ErrorPolicyTrace) 
NetworkMutableState SockAddr 
WorkerParams IO LocalAddresses SockAddr 
ErrorPolicies 
Main IO (PeerStates IO SockAddr) x

main callback

→ (Socket → IO a)

application to run on each connection

IO x 

Like worker but in IO; It provides address selection function, SocketStateChange and CompleteApplication callbacks. The Main callback is left as it's useful for testing purposes.

data IPSubscriptionTarget Source #

Constructors

IPSubscriptionTarget 

Fields

  • ispIps ∷ ![SockAddr]

    List of destinations to possibly connect to

  • ispValency ∷ !Int

    Number of parallel connections to keep actice.

ipSubscriptionTarget ∷ ∀ m addr. (MonadSTM m, MonadTime m, Ord addr) ⇒ Tracer m (SubscriptionTrace addr) → StrictTVar m (PeerStates m addr) → [addr] → SubscriptionTarget m addr Source #

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 ErrorPolicy.

ErrorPolicyUnhandledConnectionException SomeException

connect throwed an exception, which was not handled by any ErrorPolicy.

ErrorPolicyAcceptException IOException

accept throwed an exception

Instances

Instances details
Show ErrorPolicyTrace Source # 
Instance details

Defined in Ouroboros.Network.ErrorPolicy

data WithIPList a Source #

Constructors

WithIPList 

Fields

Instances

Instances details
Show a ⇒ Show (WithIPList a) Source # 
Instance details

Defined in Ouroboros.Network.Subscription.Ip

PeerState STM transactions

type BeforeConnect m s addr = Time → addr → s → STM m (ConnectDecision s) Source #

Check state before connecting to a remote peer. We will connect only if it retuns True.

runBeforeConnect ∷ (MonadSTM m, MonadTime m) ⇒ StrictTVar m s → BeforeConnect m s addr → addr → m Bool Source #

Run BeforeConnect callback in a MonadTime monad.

beforeConnectTx ∷ ∀ m addr. (MonadSTM m, Ord addr) ⇒ BeforeConnect m (PeerStates m addr) addr Source #

BeforeConnect callback: it updates peer state and return boolean value wheather to connect to it or not. If a peer hasn't been recorded in PeerStates, we add it and try to connect to it.

completeApplicationTx ∷ ∀ m addr a. (MonadAsync m, Ord addr, Ord (Async m ())) ⇒ ErrorPoliciesCompleteApplication m (PeerStates m addr) addr a Source #

mainTx ∷ (MonadThrow (STM m), MonadSTM m) ⇒ Main m (PeerStates m addr) Void Source #

Main callback. It throws an exception when the state becomes ThrowException. This exception is thrown from the main thread.

Utilitity functions

selectSockAddr ∷ SockAddr → LocalAddresses SockAddr → Maybe SockAddr Source #