Skip to content

Commit

Permalink
fix: for getValueOrErrorParallel do not return values if they come wi…
Browse files Browse the repository at this point in the history
…th errors
  • Loading branch information
aschmahmann committed Sep 5, 2023
1 parent 0ac94f8 commit 9b41d70
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions compparallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,23 @@ func getValueOrErrorParallel[T any](
ctx, cancel := withCancelAndOptionalTimeout(ctx, r.Timeout)
defer cancel()
value, empty, err := f(ctx, r.Router)
if err != nil &&
!errors.Is(err, routing.ErrNotFound) &&
!r.IgnoreError {
log.Debug("getValueOrErrorParallel: error calling router function for router ", r.Router,
" with timeout ", r.Timeout,
" and ignore errors ", r.IgnoreError,
" with error ", err,
)
select {
case <-ctx.Done():
case errCh <- err:
if err != nil {
if !errors.Is(err, routing.ErrNotFound) &&
!r.IgnoreError {
log.Debug("getValueOrErrorParallel: error calling router function for router ", r.Router,
" with timeout ", r.Timeout,
" and ignore errors ", r.IgnoreError,
" with error ", err,
)
select {
case <-ctx.Done():

Check warning on line 243 in compparallel.go

View check run for this annotation

Codecov / codecov/patch

compparallel.go#L243

Added line #L243 was not covered by tests
case errCh <- err:
}
} else {
log.Debug("getValueOrErrorParallel: not found or ignorable error for router ", r.Router,
" with timeout ", r.Timeout,
" and ignore errors ", r.IgnoreError,
)
}
return
}
Expand Down

0 comments on commit 9b41d70

Please sign in to comment.