ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.Progress

Description

The progress watchdog a registry transfer runs under. It counts the request-body bytes handed to the connection and the response-body bytes read from it, and the time spent blocked on the upstream in either direction. A transfer that waits a whole ProgressFloor window without moving the floor's bytes is stopped. The consumer's own work between reads, and the wait for the status line and headers, never count.

Synopsis

The watchdog

data Watch Source #

One transfer's progress in the current window, shared by its meters and its watchdog.

watched :: ProgressFloor -> (Watch -> IO a) -> IO (Maybe a) Source #

Run a transfer under the watchdog. Nothing means the transfer fell below the floor and was stopped. The catch sits outside the watchdog's lifetime, so a raise can never land after it.

watchedRaising :: ProgressFloor -> (Watch -> IO a) -> IO a Source #

watched for a transfer already committed to a client, which a floor miss can only abort. The failure propagates as an exception, so the response tears down instead of ending cleanly.

Metered transfers

meteredReader :: Watch -> BodyReader -> BodyReader Source #

A reader whose every read counts as a wait on the upstream, and its chunk as progress.

meteredUpload :: Watch -> RequestBody -> RequestBody Source #

The same body, handed over in slices the watch counts once each is written. A body with no bytes has no upload to watch and stays as it is.