Commit ac5f628
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 control1 parent 3020004 commit ac5f628
6 files changed
Lines changed: 976 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
0 commit comments