refactor: replace gperr.Builder with gperr.Group for concurrent error handling

- Updated various files to utilize gperr.Group for cleaner concurrency error handling.
- Removed sync.WaitGroup usage, simplifying the code structure.
- Ensured consistent error reporting across different components.
This commit is contained in:
yusing
2026-01-06 16:29:35 +08:00
parent be1f7c7ec4
commit 90948f7443
9 changed files with 62 additions and 70 deletions

View File

@@ -13,7 +13,6 @@ import (
gperr "github.com/yusing/goutils/errs"
"github.com/yusing/goutils/pool"
"github.com/yusing/goutils/task"
"golang.org/x/sync/errgroup"
)
// TODO: stats of each server.
@@ -223,7 +222,7 @@ func (lb *LoadBalancer) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
return
}
if r.URL.Path == idlewatcher.WakeEventsPath {
var errs errgroup.Group
var errs gperr.Group
// wake all servers
for _, srv := range srvs {
errs.Go(func() error {
@@ -234,7 +233,7 @@ func (lb *LoadBalancer) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
return nil
})
}
if err := errs.Wait(); err != nil {
if err := errs.Wait().Error(); err != nil {
gperr.LogWarn("failed to wake some servers", err, &lb.l)
}
}