[Feature] Expose retry attempt count to RetryPolicy::backoff_hint
- Langage dominant
- Rust
- Étoiles
- 1.3k
- Forks
- 668
- Merge moyen
- 2 j 1 h
- PR mergées (30 j)
- 29
Description
### 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).
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Start by locating RetryPolicy::backoff_hint and RetryBackoffService in the transports component, then inspect their implementations and call sites. Compare the proposed attempt-count API with the alternative fallback behavior, and treat the work as done when the selected behavior is implemented consistently and affected callers compile.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- rust
- Domaine
- networking
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 48/100