Follows the same pattern as Put/Post, accepting context, URL, and body.
Closes an obvious gap in the REST client API.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Deduplicate sentinel errors: httpx.ErrNoHealthy, ErrCircuitOpen, and
ErrRetryExhausted are now aliases to the canonical sub-package values
so errors.Is works across package boundaries
- Retry transport returns ErrRetryExhausted only when all attempts are
actually exhausted, not on early policy exit
- Balancer: pre-parse endpoint URLs at construction, replace req.Clone
with cheap shallow struct copy to avoid per-request allocations
- Circuit breaker: Load before LoadOrStore to avoid allocating a Breaker
on every request for known hosts
- Health checker: drain response body before close for connection reuse,
probe endpoints concurrently, run initial probe synchronously in Start
- Client: add Close() to shut down health checker goroutine, propagate
URL resolution errors instead of silently discarding them
- MockClock: fix lock ordering in Reset (clock.mu before t.mu), fix
timer slice compaction to avoid backing-array aliasing, extract
fireExpired to deduplicate Advance/Set
Implements the top-level httpx.Client that composes the full chain:
Logging → User Middlewares → Retry → Circuit Breaker → Balancer → Transport
- Response wrapper with JSON/XML/Bytes decoding and body caching
- NewJSONRequest helper with Content-Type and GetBody support
- Functional options: WithBaseURL, WithTimeout, WithRetry, WithEndpoints, etc.
- Integration tests covering retry, balancing, error mapping, and JSON round-trips