ouroboros-network-framework-0.1.0.1
Safe Haskell None
Language Haskell2010

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 Result addr r Source #

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

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.

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

ioSocket :: IO (addr, channel) -> Socket addr channel Source #

Expected to be useful for testing.