Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data AcceptedConnectionsLimit = AcceptedConnectionsLimit {}
- data AcceptConnectionsPolicyTrace
- type BeginConnection addr channel st r = Time -> addr -> st -> STM (HandleConnection channel st r)
- data HandleConnection channel st r where
- Reject :: forall st channel r. !st -> HandleConnection channel st r
- Accept :: forall st channel r. !st -> !(channel -> IO r) -> HandleConnection channel st r
- type ApplicationStart addr st = addr -> Async () -> st -> STM st
- type CompleteConnection addr st tr r = Result addr r -> st -> STM (CompleteApplicationResult IO addr st)
- data CompleteApplicationResult (m :: Type -> Type) addr s = CompleteApplicationResult {
- carState :: !s
- carThreads :: Set (Async m ())
- carTrace :: Maybe (WithAddr addr ErrorPolicyTrace)
- data Result addr r = Result {
- resultThread :: !(Async ())
- resultAddr :: !addr
- resultTime :: !Time
- resultValue :: !(Either SomeException r)
- type Main st t = st -> STM t
- run :: Tracer IO (WithAddr addr ErrorPolicyTrace) -> Tracer IO AcceptConnectionsPolicyTrace -> Socket addr channel -> AcceptedConnectionsLimit -> (IOException -> IO ()) -> BeginConnection addr channel st r -> ApplicationStart addr st -> CompleteConnection addr st tr r -> Main st t -> TVar st -> IO t
- data Socket addr channel = Socket {
- acceptConnection :: IO (addr, channel, IO (), Socket addr channel)
- ioSocket :: IO (addr, channel) -> Socket addr channel
Documentation
data AcceptedConnectionsLimit Source #
Policy which governs how to limit the number of accepted connections.
AcceptedConnectionsLimit | |
|
Instances
data AcceptConnectionsPolicyTrace Source #
Trace for the AcceptConnectionsLimit
policy.
ServerTraceAcceptConnectionRateLimiting DiffTime Int | |
ServerTraceAcceptConnectionHardLimit Word32 | |
ServerTraceAcceptConnectionResume Int |
Instances
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.
Reject :: forall st channel r. !st -> HandleConnection channel st r | |
Accept :: forall st channel r. !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 :: Type -> Type) addr s Source #
CompleteApplicationResult | |
|
Instances
Functor (CompleteApplicationResult m addr) Source # | |
Defined in Ouroboros.Network.ErrorPolicy fmap :: (a -> b) -> CompleteApplicationResult m addr a -> CompleteApplicationResult m addr b # (<$) :: a -> CompleteApplicationResult m addr b -> CompleteApplicationResult m addr a # |
The product of a spawned thread. We catch all (even async) exceptions.
Result | |
|
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.
run :: Tracer IO (WithAddr addr ErrorPolicyTrace) -> Tracer IO AcceptConnectionsPolicyTrace -> Socket addr channel -> AcceptedConnectionsLimit -> (IOException -> IO ()) -> 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.
Socket | |
|