| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
- data RelayResponder response = RelayResponder {
- relayStreamResponse :: Status -> ResponseHeaders -> StreamingBody -> IO response
- relayEmptyResponse :: Status -> ResponseHeaders -> IO response
- data UpstreamBody
- = StreamBody
- | NoBody
- data UpstreamResult a
- withUpstreamResult :: ExchangeClient -> ProgressFloor -> Request -> UpstreamBody -> (Status -> Bool) -> (Status -> ResponseHeaders -> IO (Status, ResponseHeaders, verdict)) -> RelayResponder response -> IO (UpstreamResult (verdict, response))
- withUpstreamResultUsing :: ReadControl -> ExchangeClient -> ProgressFloor -> Request -> UpstreamBody -> (Status -> Bool) -> (Status -> ResponseHeaders -> IO (Status, ResponseHeaders, verdict)) -> RelayResponder response -> IO (UpstreamResult (verdict, response))
- newtype UpstreamBodyFailed = UpstreamBodyFailed TransportFault
- pumpBody :: BodyReader -> (Builder -> IO ()) -> IO () -> IO ()
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 |
| NoBody | Never read the upstream body, including for |
Instances
| Show UpstreamBody Source # | |
Defined in Ecluse.Core.Server.Stream Methods showsPrec :: Int -> UpstreamBody -> ShowS # show :: UpstreamBody -> String # showList :: [UpstreamBody] -> ShowS # | |
| Eq UpstreamBody Source # | |
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 |
| UpstreamTransportFailure | The upstream connection failed before a response was available. |
| UpstreamCooling RetryAfter | Public admission refused the exchange before opening a connection. |
Instances
| Show a => Show (UpstreamResult a) Source # | |
Defined in Ecluse.Core.Server.Stream Methods showsPrec :: Int -> UpstreamResult a -> ShowS # show :: UpstreamResult a -> String # showList :: [UpstreamResult a] -> ShowS # | |
| Eq a => Eq (UpstreamResult a) Source # | |
Defined in Ecluse.Core.Server.Stream Methods (==) :: UpstreamResult a -> UpstreamResult a -> Bool # (/=) :: UpstreamResult a -> UpstreamResult a -> Bool # | |
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.
Constructors
| UpstreamBodyFailed TransportFault |
Instances
| Exception UpstreamBodyFailed Source # | |
Defined in Ecluse.Core.Server.Stream Methods toException :: UpstreamBodyFailed -> SomeException # fromException :: SomeException -> Maybe UpstreamBodyFailed # | |
| Show UpstreamBodyFailed Source # | |
Defined in Ecluse.Core.Server.Stream Methods showsPrec :: Int -> UpstreamBodyFailed -> ShowS # show :: UpstreamBodyFailed -> String # showList :: [UpstreamBodyFailed] -> ShowS # | |
| Eq UpstreamBodyFailed Source # | |
Defined in Ecluse.Core.Server.Stream Methods (==) :: UpstreamBodyFailed -> UpstreamBodyFailed -> Bool # (/=) :: UpstreamBodyFailed -> UpstreamBodyFailed -> Bool # | |