Skip to content

Commit

Permalink
fix queue client
Browse files Browse the repository at this point in the history
  • Loading branch information
gusin13 committed Nov 28, 2024
1 parent e94f144 commit ed33032
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 487 deletions.
13 changes: 9 additions & 4 deletions cmd/babylon-staking-indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import (

"github.com/joho/godotenv"
"github.com/rs/zerolog/log"
"go.uber.org/zap"

"github.com/babylonlabs-io/babylon-staking-indexer/cmd/babylon-staking-indexer/cli"
"github.com/babylonlabs-io/babylon-staking-indexer/internal/clients/bbnclient"
"github.com/babylonlabs-io/babylon-staking-indexer/internal/clients/btcclient"
"github.com/babylonlabs-io/babylon-staking-indexer/internal/config"
"github.com/babylonlabs-io/babylon-staking-indexer/internal/db"
"github.com/babylonlabs-io/babylon-staking-indexer/internal/observability/metrics"
"github.com/babylonlabs-io/babylon-staking-indexer/internal/queue"
"github.com/babylonlabs-io/babylon-staking-indexer/internal/services"
"github.com/babylonlabs-io/staking-queue-client/queuemngr"
)

func init() {
Expand Down Expand Up @@ -44,9 +45,13 @@ func main() {
log.Fatal().Err(err).Msg("error while creating db client")
}

qm, err := queue.NewQueueManager(&cfg.Queue)
// Create a basic zap logger
zapLogger, _ := zap.NewProduction()
defer zapLogger.Sync()

queueConsumer, err := queuemngr.NewQueueManager(&cfg.Queue, zapLogger)
if err != nil {
log.Fatal().Err(err).Msg("error while creating queue manager")
log.Fatal().Err(err).Msg("failed to initialize event consumer")
}

btcClient, err := btcclient.NewBTCClient(&cfg.BTC)
Expand All @@ -64,7 +69,7 @@ func main() {
log.Fatal().Err(err).Msg("error while creating btc notifier")
}

service := services.NewService(cfg, dbClient, btcClient, btcNotifier, bbnClient, qm)
service := services.NewService(cfg, dbClient, btcClient, btcNotifier, bbnClient, queueConsumer)
if err != nil {
log.Fatal().Err(err).Msg("error while creating service")
}
Expand Down
12 changes: 12 additions & 0 deletions consumer/event_consumer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package consumer

import (
"github.com/babylonlabs-io/staking-queue-client/client"
)

type EventConsumer interface {
Start() error
PushStakingEvent(ev *client.StakingEvent) error
PushUnbondingEvent(ev *client.StakingEvent) error
Stop() error
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.1
require (
github.com/avast/retry-go/v4 v4.5.1
github.com/babylonlabs-io/babylon v0.17.1
github.com/babylonlabs-io/staking-queue-client v0.4.1
github.com/babylonlabs-io/staking-queue-client v0.4.7-0.20241128065526-664aebdb9c1b
github.com/btcsuite/btcd v0.24.3-0.20241011125836-24eb815168f4
github.com/btcsuite/btcd/btcec/v2 v2.3.4
github.com/btcsuite/btcd/btcutil v1.1.6
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ github.com/babylonlabs-io/babylon v0.17.1 h1:lyWGdR7B49qDw5pllLyTW/HAM5uQWXXPZef
github.com/babylonlabs-io/babylon v0.17.1/go.mod h1:sT+KG2U+M0tDMNZZ2L5CwlXX0OpagGEs56BiWXqaZFw=
github.com/babylonlabs-io/staking-queue-client v0.4.1 h1:AW+jtrNxZYN/isRx+njqjHbUU9CzhF42Ke6roK+0N3I=
github.com/babylonlabs-io/staking-queue-client v0.4.1/go.mod h1:n3fr3c+9LNiJlyETmcrVk94Zn76rAADhGZKxX+rVf+Q=
github.com/babylonlabs-io/staking-queue-client v0.4.7-0.20241128065526-664aebdb9c1b h1:kdBDqW+wm4fiBhEiUzos9TnhmRcf6//tWyUBiBkyoqQ=
github.com/babylonlabs-io/staking-queue-client v0.4.7-0.20241128065526-664aebdb9c1b/go.mod h1:n3fr3c+9LNiJlyETmcrVk94Zn76rAADhGZKxX+rVf+Q=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down
37 changes: 0 additions & 37 deletions internal/queue/client/client.go

This file was deleted.

279 changes: 0 additions & 279 deletions internal/queue/client/rabbitmq_client.go

This file was deleted.

Loading

0 comments on commit ed33032

Please sign in to comment.