Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update events schema #75

Merged
merged 14 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using zap instead of the "github.com/rs/zerolog/log" that's already in the repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zap is needed for the queue-client, it accespt a logger in arguments 😄

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
4 changes: 2 additions & 2 deletions config/config-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ queue:
queue_user: user # can be replaced by values in .env file
queue_password: password
url: "localhost:5672"
processing_timeout: 5 # 5 second
processing_timeout: 5s # 5 second
msg_max_retry_attempts: 10
requeue_delay_time: 300
requeue_delay_time: 300s
queue_type: quorum
metrics:
host: 0.0.0.0
Expand Down
6 changes: 3 additions & 3 deletions config/config-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ queue:
queue_user: user # can be replaced by values in .env file
queue_password: password
url: "localhost:5672"
processing_timeout: 5 # 5 second
msg_max_retry_attempts: 3
requeue_delay_time: 60
processing_timeout: 5s # 5 second
msg_max_retry_attempts: 10
requeue_delay_time: 300s
queue_type: quorum
metrics:
host: 0.0.0.0
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.20241129073153-a69b329ff376
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
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ 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/babylonlabs-io/staking-queue-client v0.4.7-0.20241129073153-a69b329ff376 h1:m2jkCF17HzW59ER5iezaK0HBtVFSmEsoA88N+iT4TW4=
github.com/babylonlabs-io/staking-queue-client v0.4.7-0.20241129073153-a69b329ff376/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.

Loading
Loading