ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Stream

Description

Artifact relays with bounded memory and upstream backpressure. The connection stays open until the responder finishes. The progress floor counts upstream waits, excluding time spent waiting for the client.

Synopsis

A typed relay responder

data RelayResponder response Source #

Route-scoped responders that keep WAI response construction at the caller.

Constructors

RelayResponder 

Fields

Relaying an upstream response through

data UpstreamBody Source #

Whether a relay pumps the upstream body through, or answers bodiless.

Constructors

StreamBody

Stream the body, except for a bodiless 304.

NoBody

Never read the upstream body, including for HEAD.

Instances

Instances details
Show UpstreamBody Source # 
Instance details

Defined in Ecluse.Core.Server.Stream

Eq UpstreamBody Source # 
Instance details

Defined in Ecluse.Core.Server.Stream

data UpstreamResult a Source #

A committed relay, or the reason no response was committed.

Constructors

UpstreamRelayed a

The responder finished, including any body streaming.

UpstreamRejected Status (Maybe RetryAfter)

The upstream answered a status the caller did not accept, with any delay its Retry-After asked for.

UpstreamTransportFailure

The upstream connection failed before a response was available.

UpstreamCooling RetryAfter

Public admission refused the exchange before opening a connection.

Instances

Instances details
Show a => Show (UpstreamResult a) Source # 
Instance details

Defined in Ecluse.Core.Server.Stream

Eq a => Eq (UpstreamResult a) Source # 
Instance details

Defined in Ecluse.Core.Server.Stream

withUpstreamResult :: ExchangeClient -> ProgressFloor -> Request -> UpstreamBody -> (Status -> Bool) -> (Status -> ResponseHeaders -> IO (Status, ResponseHeaders, verdict)) -> RelayResponder response -> IO (UpstreamResult (verdict, response)) Source #

Relay accepted responses, preserving pre-commit misses and propagating failures after the commit.

withUpstreamResultUsing :: ReadControl -> ExchangeClient -> ProgressFloor -> Request -> UpstreamBody -> (Status -> Bool) -> (Status -> ResponseHeaders -> IO (Status, ResponseHeaders, verdict)) -> RelayResponder response -> IO (UpstreamResult (verdict, response)) Source #

Apply public admission and observation while retaining response ownership through the responder.

newtype UpstreamBodyFailed Source #

A body failure after response commitment requires closing the client connection. The fault never includes the upstream request.

The pump

pumpBody :: BodyReader -> (Builder -> IO ()) -> IO () -> IO () Source #

Pump chunks with one opening flush. An empty chunk marks the end of the body.