The HTTP client every home tool uses for calls that leave the machine: bounded connect, header and idle waits with no total cap, safe retries and Range resume (from agent-tools, AGT-85)
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nelson b1bb574e5d
All checks were successful
Suite release / finalize (push) Has been skipped
Suite release / scope (push) Successful in 14s
Suite release / check-build (none, ubuntu-latest) (ubuntu-latest, none) (push) Has been skipped
Suite release / build (none, ubuntu-latest) (ubuntu-latest, none) (push) Has been skipped
Suite release / reused-checks (push) Has been skipped
Suite release / deliver (push) Has been skipped
Suite release / deploy-image (push) Has been skipped
Suite release / check-package (push) Has been skipped
Suite release / deliver-prune (push) Has been skipped
Suite release / reserve (push) Has been skipped
Suite release / publish (push) Has been skipped
Suite release / module (push) Successful in 29s
The module is forgejo.romaine.life/romaine-life/netclient (#2)
2026-11-29 22:43:17 -08:00
go.mod The module is forgejo.romaine.life/romaine-life/netclient (#2) 2026-11-29 22:43:17 -08:00
netclient.go netclient moves in from agent-tools, unchanged (#1) 2026-11-29 22:31:30 -08:00
netclient_test.go netclient moves in from agent-tools, unchanged (#1) 2026-11-29 22:31:30 -08:00
README.md The module is forgejo.romaine.life/romaine-life/netclient (#2) 2026-11-29 22:43:17 -08:00

netclient

The HTTP client every home tool uses for calls that leave the machine, built for slow, lossy links (hotel Wi-Fi: a quarter-second round trip and a third of packets lost, with the tunnel home still working). A fixed total timeout fails a transfer that was still moving, and an agent then reads "the network is down"; this client fails only a transfer that has stopped.

  • No total-duration cap. Connecting (dial and TLS) is bounded by Dial, the wait for response headers by Headers, and a body by Idle: a body fails only once Idle passes with no bytes arriving.
  • Transient failures (failing to connect, timeouts, resets, a stalled body, 502/503/504) are retried with a doubling, jittered pause up to MaxPause, until GiveUp passes with no progress; the error then names the host and how long it tried.
  • Only a request that is safe to send again is retried: GET, HEAD, OPTIONS, TRACE, PUT and DELETE, or one marked Idempotent. Any request is retried when it failed before a connection was made. NoReplay limits a request to that case.
  • A GET whose body breaks part-way resumes with a Range request when the server offers ranges.
  • Each retry writes one line, to stderr or the tool's Log: slow link to <host>: <error>, retrying (n) in <pause>.

It was agent-tools' netclient package until shared packages got repositories of their own (AGT-85, AHT-258).

Using it

require forgejo.romaine.life/romaine-life/netclient v0.1.1
import "forgejo.romaine.life/romaine-life/netclient"

resp, err := netclient.Client().Get(url)            // the shared client, retries to stderr
c := netclient.New(netclient.Options{Log: logLine}) // a background tool's own log

Testing

go test ./.... The tests run against httptest servers and a fake clock, so they need no network.

Shipping

A library: the release-module topic in pipeline-templates' fleet.json tags each merge that changes the code, and every fleet repository whose go.mod requires it gets a take-up. Forgejo pushes it to its public GitHub copy, which proxy.golang.org serves to builds outside CI.