pub struct Refetch<'f, 'r> { /* private fields */ }Expand description
A fetch that starts again if its body fails in transit.
A body fails in transit in these cases:
- the connection reports an error
- the peer stays silent past the
progress_timeoutwindow - the transfer is slower than the
low_speedrule allows.
Each refetch spends one repeat of
max_retries, the count that also limits
the rounds of the fetch. So the rounds of each fetch and the refetches
between them share one budget. A refetch sends the request again, from
the first destination. It sends the Range header of the request again,
if the request has one, and adds no Range header of its own. So a
refetch asks for the whole body again, or for the same part of it.
A body that fails in another way is not fetched again, because another fetch fails in the same way. Examples are the size cap and a failure of the consumer, such as a checksum mismatch.
Implementations§
Source§impl Refetch<'_, '_>
impl Refetch<'_, '_>
Sourcepub async fn fetch(&mut self) -> Result<Fetched>
pub async fn fetch(&mut self) -> Result<Fetched>
Fetches the request, with the rest of the budget for its rounds.
§Errors
This method returns the errors that Fetcher::fetch returns.
Sourcepub async fn retry<E>(&mut self, error: E) -> Result<(), E>
pub async fn retry<E>(&mut self, error: E) -> Result<(), E>
Prepares the next refetch, or returns error if no refetch applies.
error is the error that ended the consumer of the latest body, in the
error type of the caller. If that body failed in transit and a repeat
is left, the method spends the repeat. It then waits for the backoff
delay before the next fetch.
The consumer drops the body before it calls this method. So the delay holds no connection and no admission permit.
§Errors
Returns error as it is if the latest body did not fail in transit, or
if no repeat is left.