Skip to content

Commit ac5f628

Browse files
committed
feat(http): add RetryStrategy callback and context-driven configuration
Introduce RetryStrategy, a callback-based retry mechanism that supersedes the legacy exponential-backoff RetryConfig loop. The strategy owns the attempt cap and retry decision for each HTTP attempt, supporting custom logic like Retry-After header parsing via the new RetryOnStatus helper. Add WithContext and WithLogger methods to configure clients from context objects, enabling per-feature HTTP tracing and HAR collection. TraceToStdout now deduplicates multiple calls by merging configs into a single installed middleware instead of stacking. Add CommonsHTTPContext interface for context objects to provide logger, trace config, and HAR collector. Implement metadataHARMiddleware for low-cost HAR capture (headers/timing only, no bodies). Add WriteHARFile to serialize HAR entries to disk. Add traceConfigForLevel to derive trace config from logger verbosity levels (Trace1 for headers, Trace2 for bodies), making -vvv/-vvvv flags automatically enable tracing. Breaking change: Client.traceMW and related internals are now exposed for deduplication logic; existing code using Trace() or TraceToStdout() continues to work but may see different middleware stacking behavior. Refs: HAR collection, context-driven configuration, improved retry control
1 parent 3020004 commit ac5f628

6 files changed

Lines changed: 976 additions & 25 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ cmd/hx/fixtures/hx
2323
.ginkgo/
2424
.gavel/
2525
.tmp/
26+
hack/

0 commit comments

Comments
 (0)