alloy-rs / alloy-rs/alloy

[Feature] Expose retry attempt count to RetryPolicy::backoff_hint

Offen
#4,066 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Rust
Sterne
1.3k
Forks
668
Ø Merge
2 T. 1 Std.
Gemergte PRs (30 T.)
29

Beschreibung

### 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).

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
networking
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.