From d7f488128e2ee98f03b0d62c74968b01046c0bd8 Mon Sep 17 00:00:00 2001 From: Simon Chow Date: Tue, 16 Jan 2024 14:14:01 -0500 Subject: [PATCH] Add rand archive url --- internal/utils/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/utils/main.go b/internal/utils/main.go index a59c9a6a..becb3779 100644 --- a/internal/utils/main.go +++ b/internal/utils/main.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "math/big" + "math/rand" "time" "github.com/spf13/pflag" @@ -538,7 +539,15 @@ var futureArchiveURLs = []string{ } func CreateHistoryArchiveClient(archiveURLS []string) (historyarchive.ArchiveInterface, error) { - return historyarchive.NewArchivePool(archiveURLS, historyarchive.ConnectOptions{UserAgent: "stellar-etl/1.0.0"}) + var archiveInterface historyarchive.ArchiveInterface + + archivePool, err := historyarchive.NewArchivePool(archiveURLS, historyarchive.ConnectOptions{UserAgent: "stellar-etl/1.0.0"}) + if err != nil { + return archiveInterface, err + } + + // Use random archive pool + return archivePool[int32(rand.Intn(len(archivePool)))], nil } // GetLatestLedgerSequence returns the latest ledger sequence