Documentation
¶
Overview ¶
Package httpx is the HTTP layer: a shared client, retrying JSON reads and resumable-by-existence downloads.
The retry policy is ported from core/http.py's tenacity decorators rather than re-chosen. GitHub's API is polled unauthenticated here, so it is rate-limited, and loosening the policy would fail a sync that used to work.
Index ¶
Constants ¶
const ( // UserAgent identifies the toolkit to the registries it polls. UserAgent = "icon-sets-sync (+https://github.com/ichava/icon-sets-sync)" // DefaultTimeout and DefaultDownloadTimeout match core/http.py. DefaultTimeout = 30 * time.Second DefaultDownloadTimeout = 300 * time.Second // Attempts and the backoff bounds are tenacity's: // stop_after_attempt(4), wait_exponential(multiplier=2, min=2, max=30) // for JSON, and max=60 for downloads. Attempts = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Transport is the round tripper both the JSON and download clients are
// built on. Tests supply a stub here rather than standing up an
// httptest.Server: the sandbox this is developed in refuses to bind a
// listening socket, and a suite that silently skips there would be the
// same shape of false green this estate has been bitten by before.
Transport http.RoundTripper
// Sleep is swapped by tests so the retry path can be exercised without
// waiting out the real backoff.
Sleep func(time.Duration)
}
Client performs the toolkit's HTTP requests.
func (*Client) Download ¶
Download fetches url to dest and returns dest.
Idempotent by existence: a non-empty file already at dest is kept unless force is set. The write goes to a sibling .tmp and is renamed, so an interrupted download never leaves a truncated file that the next run would treat as a complete cache hit.