Skip to content

Commit

Permalink
fix: Register base healthcheck on one server (#28)
Browse files Browse the repository at this point in the history
* fix: Register base healthcheck on one server

* pr comment

* indexer version

* gosum
  • Loading branch information
rbajollari authored Aug 21, 2024
1 parent f9cf4f8 commit 4b596b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cosmossdk.io/math v1.1.2
github.com/ethereum/go-ethereum v1.13.4
github.com/golangci/golangci-lint v1.55.2
github.com/ojo-network/indexer v0.0.5
github.com/ojo-network/indexer v0.0.6
github.com/rs/zerolog v1.31.0
github.com/spf13/viper v1.12.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ github.com/nunnatsa/ginkgolinter v0.14.1 h1:khx0CqR5U4ghsscjJ+lZVthp3zjIFytRXPTa
github.com/nunnatsa/ginkgolinter v0.14.1/go.mod h1:nY0pafUSst7v7F637e7fymaMlQqI9c0Wka2fGsDkzWg=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/ojo-network/indexer v0.0.5 h1:TsJcTzntRkMlGzLcltmybeN5Ux3gOMn3mr5FS431q1A=
github.com/ojo-network/indexer v0.0.5/go.mod h1:Zi3h9u2KGKyhKIZd0V5BcBMOh6cVySGdeo3Dv54Var8=
github.com/ojo-network/indexer v0.0.6 h1:Z1z/DkHw+XXc04B+8nkYs2woR2J+P+rmzHNSYD3uxSw=
github.com/ojo-network/indexer v0.0.6/go.mod h1:Zi3h9u2KGKyhKIZd0V5BcBMOh6cVySGdeo3Dv54Var8=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ func main() {
}

// Create new websocket and REST server for each exchange
for _, exchange := range cfg.Exchanges {
for iter, exchange := range cfg.Exchanges {
// Only register base health check on one server to avoid multiple registrations panic
var registerBaseHealthCheck bool
if iter == 0 {
registerBaseHealthCheck = true
} else {
registerBaseHealthCheck = false
}

// Initialize indexer
i := indexer.NewIndexer(logger, ctx)

// Start and maintain connection to blockchain nodes
client.MaintainConnection(exchange, i, ctx, logger)

s, err := server.NewServer(logger, cfg.Server, cfg.AssetPairs(exchange))
s, err := server.NewServer(logger, cfg.Server, cfg.AssetPairs(exchange), registerBaseHealthCheck)
if err != nil {
logger.Error().Err(err).Msg("error creating server")
cancel()
Expand Down

0 comments on commit 4b596b3

Please sign in to comment.