Skip to content

Commit

Permalink
Use threadctrl to avail of context cancellation but still rely on a w…
Browse files Browse the repository at this point in the history
…ait group to blocl until the lookups finish
  • Loading branch information
ferglor committed Oct 17, 2023
1 parent 996acf0 commit 312aa37
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/services/ocr2/plugins/ocr2keeper/evm21/streams_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ func (r *EvmRegistry) streamsLookup(ctx context.Context, checkResults []ocr2keep
}

var wg sync.WaitGroup
for i, lookup := range lookups {
wg.Add(1)
go r.doLookup(ctx, &wg, lookup, i, checkResults, lggr)
}
wg.Add(len(lookups))

r.threadCtrl.Go(func(ctx context.Context) {
for i, lookup := range lookups {
go r.doLookup(ctx, &wg, lookup, i, checkResults, lggr)
}
})

wg.Wait()

// don't surface error to plugin bc StreamsLookup process should be self-contained.
Expand Down

0 comments on commit 312aa37

Please sign in to comment.