Skip to content

Commit

Permalink
add close for pubsub
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed May 30, 2023
1 parent b44c1b8 commit 7c540fb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sectorstatemgr/sectorstatemgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func NewSectorStateMgr(cfg *config.Boost) func(lc fx.Lifecycle, sdb *db.SectorSt
},
OnStop: func(ctx context.Context) error {
cancel()
mgr.PubSub.Close()
return nil
},
})
Expand All @@ -72,15 +73,16 @@ func NewSectorStateMgr(cfg *config.Boost) func(lc fx.Lifecycle, sdb *db.SectorSt
func (m *SectorStateMgr) Run(ctx context.Context) {
duration := time.Duration(m.cfg.StorageListRefreshDuration)
log.Infof("starting sector state manager running on interval %s", duration.String())
ticker := time.NewTicker(duration)
defer ticker.Stop()

// Check immediately
err := m.checkForUpdates(ctx)
if err != nil {
log.Errorw("checking for state updates", "err", err)
}

ticker := time.NewTicker(duration)
defer ticker.Stop()

// Check every tick
for {
select {
Expand Down

0 comments on commit 7c540fb

Please sign in to comment.