ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.Exchange

Description

Bounded registry exchanges under the progress floor, the response wait, and optional public authority control.

Synopsis

The bounded exchange

boundedExchange :: (Int -> Int -> ByteString -> a) -> ExchangeClient -> ProgressFloor -> BodyLimit -> Request -> IO (Either FetchFault a) Source #

Project status, decompressed byte count, and body. Transport failures retain their typed cause.

runExchange :: ExchangeClient -> ProgressFloor -> Request -> (Response BodyReader -> IO (Either LimitError a)) -> IO (Either FetchFault a) Source #

Consume a response under the progress floor and the response wait, classifying transport and body-limit failures.

runExchangeUsing :: ReadControl -> ExchangeClient -> ProgressFloor -> Request -> (Response BodyReader -> IO (Either LimitError a)) -> IO (Either FetchFault a) Source #

Retain the controlled response lifetime for header-aware bounded consumers.

singleAttemptSettings :: ManagerSettings -> ManagerSettings Source #

Destructive clients must return uncertain transport failures for reassessment before retry.

newSingleAttemptManager :: IO Manager Source #

A typedTlsManagerSettings manager under singleAttemptSettings. newTlsManagerWith would replace its retry check and restore the replay on a reused connection.

withSuccessBody :: ExchangeClient -> ProgressFloor -> (IO ByteString -> IO (Either LimitError a)) -> Request -> IO (Either FetchFault (BodyOutcome a)) Source #

Consume a 2xx body within the response lifetime. A status outside 2xx never reaches the consumer.

withSuccessBodyUsing :: ReadControl -> ExchangeClient -> ProgressFloor -> (IO ByteString -> IO (Either LimitError a)) -> Request -> IO (Either FetchFault (BodyOutcome a)) Source #

Apply public control only to the HTTP exchange that supplies this body.

boundedRelay :: ExchangeClient -> ProgressFloor -> BodyLimit -> Request -> IO (Either FetchFault PublishRelayResponse) Source #

The exchange keeping the answered status alongside the body, for the first-party relay.

The serve-path cap

withinServeCap :: Deadlines -> ProgressFloor -> (FetchFault -> e) -> IO (Either e a) -> IO (Either e a) Source #

Fail an action that outlives the floor's serve-path cap with the transport timeout, about one sweep late.

withinServeCapOr :: Deadlines -> ProgressFloor -> a -> IO a -> IO a Source #

Answer expired once an action outlives the floor's serve-path cap, about one sweep late.

Source digests

digestingRead :: (IO ByteString -> IO (Either e a)) -> IO ByteString -> IO (Either e (a, ContentDigest)) Source #

Run a consumer over a source that hashes each chunk it passes on. A success carries the digest of every chunk read.

Metered reads

chargedRead :: (Int -> IO ()) -> IO ByteString -> IO ByteString Source #

Pay for each chunk's length before the consumer sees it.

chargedReadWith :: (ByteString -> IO ()) -> IO ByteString -> IO ByteString Source #

Pay for the observed chunk before a parser or buffer retains it.

accumulatingCharge :: (Int -> IO ()) -> IO (Int -> IO ()) Source #

Convert per-chunk costs to an absolute requirement within one read operation.

accumulatingChargeFrom :: Integer -> (Int -> IO ()) -> IO (Int -> IO (), IO Int) Source #

Report the saturated reservation, including after callback failure. Zero additions charge too, but construction does not charge the seed.

boundedChargedRead :: (Int -> IO ()) -> BodyLimit -> IO ByteString -> IO (Either LimitError (Int, ByteString)) Source #

Pay the running total of buffered chunks and their final strict copy before the bounded reader retains them.

boundedIncrementalRead :: (Int -> IO ()) -> BodyLimit -> IO ByteString -> IO (Either LimitError (Int, ByteString)) Source #

Pay each buffered chunk's own charge, never a running total, before the bounded reader retains it.

Request formation

formThen :: (UrlFormationError -> fault) -> (Request -> IO (Either fault a)) -> Either UrlFormationError Request -> IO (Either fault a) Source #

Report request-formation and exchange failures through the same error channel.