From 9b41d704202483f1a06ddb5f6a63e33970a65121 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Tue, 5 Sep 2023 15:07:49 -0400 Subject: [PATCH] fix: for getValueOrErrorParallel do not return values if they come with errors --- compparallel.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/compparallel.go b/compparallel.go index 4c12188..f84f6b5 100644 --- a/compparallel.go +++ b/compparallel.go @@ -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(): + 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 }