Expand description
The one retry policy: bounded attempts, one backoff, one classification of transient versus permanent. Retry is the second choice; see the module docs for what must never be routed through it. The one retry policy: bounded attempts, one backoff, one classification.
§Why this module is small on purpose
Retry is the SECOND choice, never the first. A failure that can be prevented by design must be prevented, because a retry that fires is evidence of a defect rather than a success. The trap this module is shaped to avoid is “it will just retry” becoming a reason to ship a racy read, an unbounded allocation, or a path that fails under ordinary conditions.
Three deliberate properties enforce that:
- No catch-all cause. [
classify_io] returnsNonefor anything it does not recognise, andNonemeans permanent: the error is returned unchanged and the operation is not attempted again. Making a new failure recoverable therefore requires naming it, in public, inkeyhog_profile::RetryCause. There is no bucket to quietly widen. - Every attempt is counted. [
retry_classified] records onekeyhog_profile::record_retryper retry attempt, whether or not the retry eventually succeeded. A path that silently retries a thousand times reports a thousand, so it shows up as a defect rather than as comfort. - One bound, one backoff. [
RetryPolicy::DEFAULT] is the only policy. Callers do not get to pick a bigger number because their path is flakier; a path that needs more attempts needs a fix instead.
§What must never be routed through here
Cap refusals. The docker tar entry-count cap, the docker unpack budget, the
PDF string-parser work budget, --max-file-size, and the seventeen
configured source limits are deliberate refusals of input that is too big,
too many, or hostile. Retrying a hostile input turns a denial-of-service
defence into a denial of service. They stay one-shot refusals and are
reported as coverage gaps, never as transient failures.
Equally: a permission denial, a genuinely absent operator-supplied path, and a malformed URL are permanent. They fail identically on every attempt, so a retry only burns the bound and delays the report.
Structs§
- Opened
File - A file and the metadata of the exact inode that was opened.
- Retry
Policy - Bounded attempts with exponential backoff.
- Retrying
Content Source - Wraps a
FileContentSourceso its transient arm is retried under the shared policy and its permanent arm is not.
Enums§
- Path
Origin - Who named the path, which decides whether “not found” is a race or a fact.
Functions§
- classify_
io - Classify an IO error, or return
Nonewhen it is permanent. - open_
enumerated - Open an already-enumerated path once and take its metadata from the HANDLE.
- retry_
classified - Run
opunder the shared policy, retrying only whatclassifynames. - retry_
io retry_classifiedspecialised toio::Errorandclassify_io.