Skip to main content

Module transport

Module transport 

Source
Expand description

HTTP transport shared by every forge adapter.

Retrying, timing out, paging, and mapping a status to a failure class are the same problem for Forgejo and GitHub; only the paths and payloads differ. Adapter-specific status meaning (for example, that Forgejo answers 403 on branch protection create when the rule already exists) is resolved by the one call site that needs it, by matching on the TransportError variant that call produced.

StructsΒ§

Http
Shared HTTP transport for a forge’s REST API.
RequestLabel
The method and path of a request, as it appears in an error.
RetryPolicy
How a retryable failure is retried before it is reported.
TransportBuildError
Failure building the underlying HTTP client.

EnumsΒ§

TransportError
Anything that stops a request from producing a usable answer.

ConstantsΒ§

DEFAULT_PAGE_LIMIT πŸ”’
The most pages a listing may span unless Http::with_page_limit says otherwise.
MAX_RATE_LIMIT_WAIT πŸ”’
The longest wait a rate-limited request honours. A forge that asks for more makes the request fail with TransportError::RateLimitWaitTooLong.
RATE_LIMIT_REMAINING πŸ”’
RATE_LIMIT_RESET πŸ”’

FunctionsΒ§

log_retry πŸ”’
Log a retryable failure before the attempt that follows it.
rate_limit_wait πŸ”’
How long the response asks the caller to wait before retrying.
retry_wait πŸ”’
The wait before retrying error, which is the wait the forge stated or else backoff. A stated wait above the cap fails the request.
retryable πŸ”’
A rate limit is retried for every method, because the forge refused the request without applying it. Anything else is retried only for an idempotent method, because it does not tell whether the forge applied it.
summarize
Trim a forge error body so a huge HTML page cannot flood the output.