[Feature] Expose retry attempt count to RetryPolicy::backoff_hint
- 主要語言
- Rust
- 星號
- 1.3k
- 分支
- 668
- 平均合併
- 2 天 2 小時
- 30 天內合併 PR
- 29
描述
### Component
transports
### Describe the feature you would like
RetryPolicy::backoff_hint only receives the error:
` fn backoff_hint(&self, error: &TransportError) -> Option;`
When it returns None, RetryBackoffService falls back to a constant initial_backoff on every attempt — there is no exponential growth:
```
let backoff_hint = this.policy.backoff_hint(&err);
let next_backoff = backoff_hint.unwrap_or_else(|| this.initial_backoff());
```
Without access to the current attempt number, a custom policy cannot implement standard exponential backoff, e.g.:
` next_backoff = initial_backoff * (1 + backoff_coefficient)^(num_retries - 1)`
Proposal: pass the attempt count to the policy, e.g.
` fn backoff_hint(&self, error: &TransportError, num_retries: u32) -> Option;`
(or a context struct to keep it extensible). Alternatively, implement exponential backoff with a max ceiling directly in RetryBackoffService when no hint is
returned.
### Additional context
Downstream use case: hoprnet/blokli — custom retry policy with configurable initial_backoff, backoff_coefficient, max_backoff, currently unable to apply
them (hoprnet/hoprnet#7140).
貢獻指南
評估
這個 Issue 還沒有評估資料。