Commit 7da59f5
feat(transport): add DoH connection self-healing (transparent retry + pool rebuild) (#42)
* feat(transport): add DoH connection self-healing (transparent retry + pool rebuild)
DohClient previously had no self-healing, unlike TcpMuxClient/DotMuxClient/
DoqMuxClient. When a proxy node flapped and DoH connections turned half-open,
reqwest reused the dead connections indefinitely (POST is non-idempotent so
hyper won't auto-retry), causing persistent 3s timeouts until restart (#41).
This adds the two safeguards mirroring the mux clients, adapted to reqwest's
constraints (no per-connection reset, no reuse signal):
- Transparent retry: on transport error (timeout/connect/IO), retry once with a
fresh-connection budget (>=1.5s); DNS queries are semantically idempotent.
- Pool rebuild: per-upstream consecutive error counter; at threshold (default 3,
configurable via doh_health_check_error_threshold), rebuild the reqwest::Client
— drop evicts the dead connection pool.
Uses ArcSwap<DohHttpClient> for a hot-swappable pool (already a repo dependency)
and DashMap for per-upstream error counts. The send() signature and all callers
are unchanged.
Tests cover the healing contract (threshold rebuild, counter reset, per-upstream
isolation, error classification) plus an empirical test proving that dropping a
reqwest::Client closes its pooled keep-alive connections (the rebuild premise).
Closes #41
* style: apply rustfmt formatting to DoH self-healing tests
---------
Co-authored-by: kix <olices@9up.in>1 parent e521751 commit 7da59f5
3 files changed
Lines changed: 376 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
134 | 138 | | |
135 | 139 | | |
136 | 140 | | |
| |||
255 | 259 | | |
256 | 260 | | |
257 | 261 | | |
| 262 | + | |
258 | 263 | | |
259 | 264 | | |
260 | 265 | | |
| |||
911 | 916 | | |
912 | 917 | | |
913 | 918 | | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
914 | 923 | | |
915 | 924 | | |
916 | 925 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| |||
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
344 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
345 | 349 | | |
346 | 350 | | |
347 | 351 | | |
| |||
0 commit comments