You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’d like to propose a feature that could enhance the robustness of applications using alloy by implementing a built-in fallback mechanism for the http transport layer. This would help manage scenarios where the primary RPC provider is unavailable, improving reliability without requiring developers to implement custom in-app solutions or gateways.
I see 2 main benefits with such design:
"zero-cost" reliability: by automatically switching to a fallback provider, the app availability increases (while users simply need to inform an extra rpc url when initializing the provider).
better dev-ex: a built-in solution reduces development time for devs that would otherwise implement custom mechanisms + ensures consistency across apps.
Because of that i thought of implementing a new http transport to support multiple clients and potentially multiple request orchestration modes (although we could keep it simple and only use it as a fallback). Here the proposed impl:
then we could enhance the ProviderBuilder so that users would simply do something like:
//! Example of creating an HTTP provider using the `on_multi_http` method on the `ProviderBuilder`.use alloy::providers::{Provider,ProviderBuilder};use eyre::Result;#[tokio::main]asyncfnmain() -> eyre::Result<()>{// Set up the HTTP transport which is consumed by the RPC client.let primary = "https://eth.merkle.io".parse()?;let fallback = "https://eth.llamarpc.com".parse()?;// Create a provider with the HTTP transport with fallback using the `reqwest` crate.let provider = ProviderBuilder::new().on_multi_http(primary, fallback,MultiClientMode::Fallback);Ok(())}
do you think that this approach is sound?
do you foresee any potential challenges or limitations that i should consider?
I am eager to implement it myself if you guys think that it is a good idea, but design validation would be appreciated.
Thanks!
The text was updated successfully, but these errors were encountered:
Component
rpc, transports
Describe the feature you would like
I’d like to propose a feature that could enhance the robustness of applications using alloy by implementing a built-in fallback mechanism for the http transport layer. This would help manage scenarios where the primary RPC provider is unavailable, improving reliability without requiring developers to implement custom in-app solutions or gateways.
I see 2 main benefits with such design:
Because of that i thought of implementing a new http transport to support multiple clients and potentially multiple request orchestration modes (although we could keep it simple and only use it as a fallback). Here the proposed impl:
then we could enhance the
ProviderBuilder
so that users would simply do something like:I am eager to implement it myself if you guys think that it is a good idea, but design validation would be appreciated.
Thanks!
The text was updated successfully, but these errors were encountered: