Skip to content

Commit

Permalink
Using base module logger in receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
k-karuna committed Dec 19, 2024
1 parent b9395a2 commit 6aa2dff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions pkg/indexer/sqd_receiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"github.com/dipdup-io/workerpool"
"github.com/dipdup-net/indexer-sdk/pkg/modules"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"sync"
"time"

Expand Down Expand Up @@ -41,7 +39,6 @@ type Receiver struct {
processing map[uint64]struct{}
processingMx *sync.Mutex
result chan rcvr.Result
log zerolog.Logger
timeout time.Duration
wg *sync.WaitGroup
mx *sync.RWMutex
Expand All @@ -68,7 +65,6 @@ func New(cfg config.Config,
blocks: make(chan *api.SqdBlockResponse, cfg.ThreadsCount*10),
processing: make(map[uint64]struct{}),
processingMx: new(sync.Mutex),
log: log.With().Str("module", "subsquid_receiver").Logger(),
timeout: time.Duration(cfg.Timeout) * time.Second,
wg: new(sync.WaitGroup),
mx: new(sync.RWMutex),
Expand All @@ -87,7 +83,7 @@ func New(cfg config.Config,

// Start -
func (r *Receiver) Start(ctx context.Context) {
r.log.Info().Msg("starting subsquid receiver...")
r.Log.Info().Msg("starting subsquid receiver...")
level := r.getIndexerHeight()
if r.startLevel > level {
level = r.startLevel
Expand All @@ -102,7 +98,7 @@ func (r *Receiver) Start(ctx context.Context) {

// Close -
func (r *Receiver) Close() error {
r.log.Info().Msg("closing...")
r.Log.Info().Msg("closing...")
r.wg.Wait()

if err := r.pool.Close(); err != nil {
Expand Down Expand Up @@ -145,7 +141,7 @@ func (r *Receiver) Results() <-chan rcvr.Result {
}

func (r *Receiver) GetSqdWorkerRanges(ctx context.Context, fromLevel, height uint64) ([]BlocksToWorker, error) {
r.log.Info().
r.Log.Info().
Uint64("head", height).
Msg("retrieving subsquid workers...")

Expand Down Expand Up @@ -178,7 +174,7 @@ func (r *Receiver) GetSqdWorkerRanges(ctx context.Context, fromLevel, height uin

currentLevel = lastBlock.Header.Number + 1

r.log.Info().
r.Log.Info().
Uint64("from level", workerSegment.From).
Uint64("to level", workerSegment.To).
Msg("retrieved worker for blocks")
Expand Down
4 changes: 2 additions & 2 deletions pkg/indexer/sqd_receiver/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (r *Receiver) sync(ctx context.Context) {
Msg("rollback detected by block height")
}

r.log.Info().
r.Log.Info().
Uint64("indexer_block", r.getIndexerHeight()).
Uint64("node_block", head).
Msg("syncing...")
Expand Down Expand Up @@ -48,6 +48,6 @@ func (r *Receiver) sync(ctx context.Context) {
}
}

r.log.Info().Uint64("height", r.getIndexerHeight()).Msg("synced")
r.Log.Info().Uint64("height", r.getIndexerHeight()).Msg("synced")
return

Check failure on line 52 in pkg/indexer/sqd_receiver/sync.go

View workflow job for this annotation

GitHub Actions / Linter

S1023: redundant `return` statement (gosimple)
}

0 comments on commit 6aa2dff

Please sign in to comment.