ouroboros-network-framework-0.13.1.0: Ouroboros network framework
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Network.Subscription.Worker

Synopsis

Documentation

type SocketStateChange m s addr = SocketState m addr → s → STM m s Source #

Callback which fires: when we create or close a socket.

data SocketState m addr Source #

Constructors

CreatedSocket !addr !(Async m ()) 
ClosedSocket !addr !(Async m ()) 

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 ConnectResult Source #

GADT which classifies connection result.

Constructors

ConnectSuccess

Successful connection.

ConnectSuccessLast

Successfully connection, reached the valency target. Other ongoing connection attempts will be killed.

ConnectValencyExceeded

Someone else manged to create the final connection to a target before us.

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 
ConnectionErrorException e ⇒ !Time → !addr → !e → Result addr r 
ApplicationErrorException e ⇒ !Time → !addr → !e → Result addr r 

type Main m s t = s → STM m t Source #

Given current state retry too keep the subscription worker going. When this transaction returns, all the threads spawned by the worker will be killed.

type StateVar m s = StrictTVar m s Source #

Mutable state kept by the worker. All the workers in this module are polymorphic over the state type. The state is updated with two callbacks:

  • CompleteConnect - STM transaction which runs when the connect call returned, if it thrown an exception it will be passed to the callback.
  • CompleteApplication - STM transaction which runs when application returned. It will receive the result of the application or an exception raised by it.

data LocalAddresses addr Source #

Constructors

LocalAddresses 

Fields

  • laIpv4Maybe addr

    Local IPv4 address to use, Nothing indicates don't use IPv4

  • laIpv6Maybe addr

    Local IPv6 address to use, Nothing indicates don't use IPv6

  • laUnixMaybe addr

    Local Unix address to use, Nothing indicates don't use Unix sockets

Instances

Instances details
Semigroup (LocalAddresses addr) Source # 
Instance details

Defined in Ouroboros.Network.Subscription.Worker

Methods

(<>)LocalAddresses addr → LocalAddresses addr → LocalAddresses addr #

sconcatNonEmpty (LocalAddresses addr) → LocalAddresses addr #

stimesIntegral b ⇒ b → LocalAddresses addr → LocalAddresses addr #

Show addr ⇒ Show (LocalAddresses addr) Source # 
Instance details

Defined in Ouroboros.Network.Subscription.Worker

Methods

showsPrecIntLocalAddresses addr → ShowS #

showLocalAddresses addr → String #

showList ∷ [LocalAddresses addr] → ShowS #

Eq addr ⇒ Eq (LocalAddresses addr) Source # 
Instance details

Defined in Ouroboros.Network.Subscription.Worker

Methods

(==)LocalAddresses addr → LocalAddresses addr → Bool #

(/=)LocalAddresses addr → LocalAddresses addr → Bool #

Subscription worker

data WorkerCallbacks m s addr a t Source #

Worker STM callbacks

data WorkerParams m localAddrs addr Source #

Worker parameters

Constructors

WorkerParams 

Fields

worker Source #

Arguments

∷ ∀ s sock localAddrs addr a x. Ord addr 
Tracer IO (SubscriptionTrace addr) 
Tracer IO (WithAddr addr ErrorPolicyTrace) 
ConnectionTable IO addr 
StateVar IO s 
Snocket IO sock addr 
→ (sock → addr → IO ()) 
WorkerCallbacks IO s addr a x 
WorkerParams IO localAddrs addr 
→ (sock → IO a)

application

IO x 

This is the most abstract worker, which puts all the pieces together. It will execute until main :: Main m s t returns. It runs subscriptionLoop in a new threads and will exit when it dies. Spawn threads are cancelled in a finally callback by throwing SubscriberError.

Note: This function runs in IO only because MonadSTM does not yet support orElse, PR #432.

Socket API

safeConnect Source #

Arguments

MonadMask m 
Snocket m sock addr 
→ (sock → addr → m ())

configure the socket

→ addr

remote addr

→ addr

local addr

→ m ()

allocate extra action; executed with async exceptions masked in the allocation action of bracket

→ m ()

release extra action; executed with async exceptions masked in the closing action of bracket

→ ((∀ x. m x → m x) → sock → Either SomeException () → m t)

continuation executed with async exceptions masked; it receives: unmask function, allocated socket and connection error.

→ m t 

Allocate a socket and connect to a peer, execute the continuation with async exceptions masked. The continuation receives the unmask callback.

Constants

defaultConnectionAttemptDelayDiffTime Source #

Time to wait between connection attempts when we don't have any DeltaQ info.

minConnectionAttemptDelayDiffTime Source #

Minimum time to wait between connection attempts.

maxConnectionAttemptDelayDiffTime Source #

Maximum time to wait between connection attempts.

ipRetryDelayDiffTime Source #

Minimum time to wait between ip reconnects

Errors

Tracing