Skip to content

Commit

Permalink
fix: onNewDiscCallback should be called before srv existence check
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Selivanov committed Jun 23, 2023
1 parent 2a8a4e8 commit 4480129
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions services_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ func (p *ServicesPool) DiscoverServices() error {

// TODO for the best scaling we need to change this part to map-based compare mechanic
for _, newService := range newServices {
if p.list.IsServiceExists(newService) {
continue
}

if newService == nil {
logger.Log().Warn("newService is nil during discovery")
continue
Expand All @@ -172,13 +168,16 @@ func (p *ServicesPool) DiscoverServices() error {
continue
}

p.list.Add(mutatedService)

if p.onNewDiscCallback != nil {
if err := p.onNewDiscCallback(mutatedService); err != nil {
logger.Log().Warn(fmt.Sprintf("callback on new discovered service: %s", err))
}
}

if p.list.IsServiceExists(newService) {
continue
}
p.list.Add(mutatedService)
}
return nil
}
Expand Down

0 comments on commit 4480129

Please sign in to comment.