alloy-rs / alloy-rs/alloy

[Feature] Multi-endpoint fallback for PubSub connections

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

Beschreibung

### Component

provider, pubsub

### Describe the feature you would like

`FallbackService` handles request/response failover across multiple HTTP transports, but there's no equivalent for PubSub connections. When a WS connection drops, `PubSubService` retries the same endpoint — if that endpoint is permanently down, subscriptions are lost.

I ran into this in [paradigmxyz/reth#22648](https://github.com/paradigmxyz/reth/pull/22648) where I needed WS failover for reth's debug consensus client. The reviewer suggested using Alloy's fallback layer, but `FallbackService` operates on `RequestPacket`/`ResponsePacket` — it has no concept of stateful subscriptions.

Would a `PubSubConnect` wrapper that cycles through multiple endpoints on reconnection be welcome? The existing `try_reconnect()` override point in `PubSubService`'s retry loop seems like a natural fit, requiring minimal changes to existing code.

Happy to put up a PR if this approach sounds reasonable.

### Additional context

_No response_

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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