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

Ouroboros.Network.Server.Socket

Synopsis

Documentation

data AcceptedConnectionsLimit Source #

Policy which governs how to limit the number of accepted connections.

Constructors

AcceptedConnectionsLimit 

Fields

data AcceptConnectionsPolicyTrace Source #

Trace for the AcceptConnectionsLimit policy.

type BeginConnection addr channel st r = Time → addr → st → STM (HandleConnection channel st r) Source #

What to do on a new connection: accept and run this IO, or reject.

data HandleConnection channel st r where Source #

What to do with a new connection: reject it and give a new state, or accept it and give a new state with a continuation to run against the resulting channel. See also CompleteConnection, which is run for every connection when it finishes, and can also update the state.

Constructors

Reject ∷ !st → HandleConnection channel st r 
Accept ∷ !st → !(channel → IO r) → HandleConnection channel st r 

type ApplicationStart addr st = addr → Async () → st → STM st Source #

A call back which runs when application starts;

It is needed only because BeginConnection does not have access to the thread which runs the application.

type CompleteConnection addr st tr r = Result addr r → st → STM (CompleteApplicationResult IO addr st) Source #

How to update state when a connection finishes. Can use throwSTM to terminate the server.

TODO: remove async, use `Async m ()` from MonadAsync.

data CompleteApplicationResult m addr s Source #

Constructors

CompleteApplicationResult 

Fields

Instances

Instances details
Functor (CompleteApplicationResult m addr) Source # 
Instance details

Defined in Ouroboros.Network.ErrorPolicy

Methods

fmap ∷ (a → b) → CompleteApplicationResult m addr a → CompleteApplicationResult m addr b #

(<$) ∷ a → CompleteApplicationResult m addr b → CompleteApplicationResult m addr a #

data Result addr r Source #

The product of a spawned thread. We catch all (even async) exceptions.

Constructors

Result 

Fields

type Main st t = st → STM t Source #

Given a current state, retry unless you want to stop the server. When this transaction returns, any running threads spawned by the server will be killed.

It's possible that a connection is accepted after the main thread returns, but before the server stops. In that case, it will be killed, and the CompleteConnection will not run against it.

runTracer IO (WithAddr addr ErrorPolicyTrace) → Tracer IO AcceptConnectionsPolicyTraceSocket addr channel → AcceptedConnectionsLimit → (IOExceptionIO ()) → BeginConnection addr channel st r → ApplicationStart addr st → CompleteConnection addr st tr r → Main st t → TVar st → IO t Source #

Run a server.

data Socket addr channel Source #

Abstraction of something that can provide connections. A Socket can be used to get a `Socket SockAddr (Channel IO Lazy.ByteString)` It's not defined in here, though, because we don't want the dependency on typed-protocols or even on network.

Constructors

Socket 

Fields

ioSocketIO (addr, channel) → Socket addr channel Source #

Expected to be useful for testing.