celestia-node
celestia-node copied to clipboard
feat(api/client): add support for multiple endpoints with failover
Implements support for multiple endpoints in celestia client library to provide failover capabilities for both Bridge DA and Core gRPC connections.
Changes
- Add
AdditionalBridgeDAAddrsfield toReadConfigfor multiple bridge endpoints - Add
AdditionalCoreGRPCConfigsfield toCoreGRPCConfigfor multiple core endpoints - Introduce
MultiClientwithNewMultiEndpoint()constructor - Add validation for additional endpoint configurations
- Update documentation and examples
Usage
cfg := client.Config{
ReadConfig: client.ReadConfig{
BridgeDAAddr: "http://primary:26658",
AdditionalBridgeDAAddrs: []string{"http://backup:26658"},
},
SubmitConfig: client.SubmitConfig{
CoreGRPCConfig: client.CoreGRPCConfig{
Addr: "primary:9090",
AdditionalCoreGRPCConfigs: []client.CoreGRPCConfig{
{Addr: "backup:9090", TLSEnabled: true},
},
},
},
}
multiClient, err := client.NewMultiEndpoint(ctx, cfg, kr)
Fixes #4487
Codecov Report
:x: Patch coverage is 33.33333% with 122 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 35.26%. Comparing base (2469e7a) to head (3ec4c7b).
:warning: Report is 592 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #4617 +/- ##
==========================================
- Coverage 44.83% 35.26% -9.58%
==========================================
Files 265 304 +39
Lines 14620 24504 +9884
==========================================
+ Hits 6555 8641 +2086
- Misses 7313 14905 +7592
- Partials 752 958 +206
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.