celestia-node icon indicating copy to clipboard operation
celestia-node copied to clipboard

feat(api/client): add support for multiple endpoints with failover

Open DeVikingMark opened this issue 3 months ago • 1 comments

Implements support for multiple endpoints in celestia client library to provide failover capabilities for both Bridge DA and Core gRPC connections.

Changes

  • Add AdditionalBridgeDAAddrs field to ReadConfig for multiple bridge endpoints
  • Add AdditionalCoreGRPCConfigs field to CoreGRPCConfig for multiple core endpoints
  • Introduce MultiClient with NewMultiEndpoint() 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

DeVikingMark avatar Oct 07 '25 18:10 DeVikingMark

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.

Files with missing lines Patch % Lines
api/client/client.go 27.86% 43 Missing and 1 partial :warning:
api/client/grpc.go 17.77% 37 Missing :warning:
api/client/example/example.go 0.00% 28 Missing :warning:
api/client/read_client.go 73.46% 9 Missing and 4 partials :warning:
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.

codecov-commenter avatar Oct 07 '25 19:10 codecov-commenter