Skip to content

Commit

Permalink
Add ability to create RPC service chain
Browse files Browse the repository at this point in the history
We want to update the `fetch` middleware in `eth-json-rpc-middleware`
and the Infura middleware in `eth-json-rpc-infura` to automatically fail
over to alternate RPC endpoints when the desired endpoint is down. To do
this, we need a way to string together a collection of RPC services,
where the first service represents the primary endpoint, the second
service is failover for the first, the third service is a failover for
the second, etc. This composite object should conform to the same
interface as an RPC service so consumers do not have to care whether
they are working with a single endpoint or a chain of them.

Also expose `RpcService`, `RpcServiceChain`, and `AbstractRpcService`,
since this completes the work that we should need to do to these
packages in order to proceed to others.
  • Loading branch information
mcmire committed Jan 30, 2025
1 parent c9c747f commit 7c711aa
Show file tree
Hide file tree
Showing 3 changed files with 719 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/network-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `RpcService` for requesting a JSON-RPC endpoint using the retry and circuit breaker patterns, optionally forwarding to a failover endpoint if down
- Add `RpcServiceChain` for connecting primary and failover RPC endpoints together into a single RPC service-like thing
- Add `AbstractRpcService`, the interface for all RPC services

### Changed

- Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.0` ([#5079](https://github.com/MetaMask/core/pull/5079))
Expand Down
Loading

0 comments on commit 7c711aa

Please sign in to comment.