-
Notifications
You must be signed in to change notification settings - Fork 5.6k
replace most uses of hashicorp/go-multierror for stdlib #13176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Sebastiaan van Stijn <[email protected]>
…group The go-multierror Group is just a shallow wrapper around sync.WaitGroup; https://github.com/hashicorp/go-multierror/blob/v1.1.1/group.go#L5-L38 It does not limit concurrency, but handles synchronisation to collect all errors (if any) in a go-multierror. This patch replaces the go-multierror.Group for a sync.ErrGroup (which is slightly easier to use, and does allow for limiting concurrency if wanted), and a basic slice with mutex to collect the errors and to produce a stdlib multi-error through errors.Join Signed-off-by: Sebastiaan van Stijn <[email protected]>
The go-multierror Group is just a shallow wrapper around sync.WaitGroup; https://github.com/hashicorp/go-multierror/blob/v1.1.1/group.go#L5-L38 This patch replaces the go-multierror.Group for a sync.WaitGroup (we probably don't need to limit concurrency for this one) and stdlib multi- errors. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
| var ( | ||
| eg errgroup.Group | ||
| errMu sync.Mutex | ||
| errs = make([]error, 0, len(containers)*2) // max 2 errs per container | ||
| ) | ||
|
|
||
| eg.SetLimit(16) // arbitrary limit, adjust to taste :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this one, I used an errgroup so that we have the option to limit concurrency, but we could use a regular waitgroup as well
| for _, exporter := range m.exporters { | ||
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() | ||
| if err := exporter.ExportSpans(ctx, spans); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't use a errgroup for these, but we could if we want the slightly easier UX. But once we have go1.25 as minimum version, these can be simpified using WaitGroup.Go; https://pkg.go.dev/sync#WaitGroup.Go
|
I have one more remaining after this to update |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [docker/compose](https://github.com/docker/compose) | patch | `v2.39.2` -> `v2.39.3` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>docker/compose (docker/compose)</summary> ### [`v2.39.3`](https://github.com/docker/compose/releases/tag/v2.39.3) [Compare Source](docker/compose@v2.39.2...v2.39.3) #### What's Changed ##### ✨ Improvements - Add completions for the `--progress` flag by [@​m4rch3n1ng](https://github.com/m4rch3n1ng) in [#​13158](docker/compose#13158) ##### 🐛 Fixes - Add `--provenance` and `--sbom` flag to generated `bake` command line, by [@​glours](https://github.com/glours) in [#​13147](docker/compose#13147) - Fix runtime operations failing when env file is missing by [@​maxproske](https://github.com/maxproske) in [#​13156](docker/compose#13156) - Check the assume yes publish flag command before the presence of bind mounts by [@​glours](https://github.com/glours) in [#​13151](docker/compose#13151) - Fix: incorrect time when last tag time is not set by [@​kianelbo](https://github.com/kianelbo) in [#​13171](docker/compose#13171) - Fix sigint/sigterm support in logs `--follow` by [@​ndeloof](https://github.com/ndeloof) in [#​13193](docker/compose#13193) - Prefer application container vs one-off running `exec` without index by [@​ndeloof](https://github.com/ndeloof) in [#​13178](docker/compose#13178) - Only force plain mode build if progress is set to `auto` by [@​ndeloof](https://github.com/ndeloof) in [#​13181](docker/compose#13181) - Only propagate os.Env to bake, not the whole project.Environment by [@​ndeloof](https://github.com/ndeloof) in [#​13180](docker/compose#13180) - Detect container is restarted by [@​ndeloof](https://github.com/ndeloof) in [#​13210](docker/compose#13210) - Fix run `--build` support for `service:* reference` in additional\_context by [@​ndeloof](https://github.com/ndeloof) in [#​13183](docker/compose#13183) - Detect compose run wit `--host` and set `DOCKER_HOST` accordingly running bake by [@​ndeloof](https://github.com/ndeloof) in [#​13182](docker/compose#13182) ##### 🔧 Internal - Refactor to use maps.Copy by [@​cuiweixie](https://github.com/cuiweixie) in [#​13174](docker/compose#13174) - Replace most uses of hashicorp/go-multierror for stdlib by [@​thaJeztah](https://github.com/thaJeztah) in [#​13176](docker/compose#13176) - pkg/compose: composeService.Up: rewrite without go-multierror by [@​thaJeztah](https://github.com/thaJeztah) in [#​13177](docker/compose#13177) - Use enum-consts for State and Health by [@​thaJeztah](https://github.com/thaJeztah) in [#​13186](docker/compose#13186) - Unquote volume names in creation events by [@​rrjjvv](https://github.com/rrjjvv) in [#​13188](docker/compose#13188) - pkg/compose: use state consts from moby API by [@​thaJeztah](https://github.com/thaJeztah) in [#​13216](docker/compose#13216) - Document (hidden) `--tty` `--interactive` flags by [@​ndeloof](https://github.com/ndeloof) in [#​13201](docker/compose#13201) ##### ⚙️ Dependencies - go.mod: github.com/docker/buildx v0.27.0 by [@​thaJeztah](https://github.com/thaJeztah) in [#​13170](docker/compose#13170) - Build(deps): bump go.uber.org/mock from 0.5.2 to 0.6.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​13162](docker/compose#13162) - go.mod: bump buildkit v0.24.0-rc1, buildx v0.28.0-rc1 by [@​thaJeztah](https://github.com/thaJeztah) in [#​13185](docker/compose#13185) - Build(deps): bump github.com/stretchr/testify from 1.10.0 to 1.11.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​13184](docker/compose#13184) - go.mod: bump buildx v0.28.0-rc2, buildkit v0.24.0-rc2 by [@​thaJeztah](https://github.com/thaJeztah) in [#​13197](docker/compose#13197) - Build(deps): bump github.com/spf13/pflag from 1.0.7 to 1.0.9 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​13195](docker/compose#13195) - Build(deps): bump github.com/spf13/cobra from 1.9.1 to 1.10.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​13198](docker/compose#13198) - go.mod: bump github.com/docker/docker, docker/cli v28.4.0 by [@​thaJeztah](https://github.com/thaJeztah) in [#​13168](docker/compose#13168) - Build(deps): bump github.com/docker/buildx from 0.28.0-rc2 to 0.28.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​13207](docker/compose#13207) - Build(deps): bump github.com/spf13/pflag from 1.0.9 to 1.0.10 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​13200](docker/compose#13200) - Bump golang to version 1.24.7 by [@​glours](https://github.com/glours) in [#​13219](docker/compose#13219) - Build(deps): bump golang.org/x/sync from 0.16.0 to 0.17.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​13218](docker/compose#13218) - Build(deps): bump golang.org/x/sys from 0.35.0 to 0.36.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​13217](docker/compose#13217) - Bump compose-go to version v2.8.2 by [@​glours](https://github.com/glours) in [#​13220](docker/compose#13220) #### New Contributors - [@​cuiweixie](https://github.com/cuiweixie) made their first contribution in [#​13174](docker/compose#13174) - [@​m4rch3n1ng](https://github.com/m4rch3n1ng) made their first contribution in [#​13158](docker/compose#13158) - [@​kianelbo](https://github.com/kianelbo) made their first contribution in [#​13171](docker/compose#13171) - [@​rrjjvv](https://github.com/rrjjvv) made their first contribution in [#​13188](docker/compose#13188) **Full Changelog**: <docker/compose@v2.39.2...v2.39.3> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS45OC4xIiwidXBkYXRlZEluVmVyIjoiNDEuOTguMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
cmd/formatter: remove unused SetMultiErrorFormat
internal/sync: replace go-multierror.Group with golang.org/x/sync/errgroup
The go-multierror Group is just a shallow wrapper around sync.WaitGroup;
https://github.com/hashicorp/go-multierror/blob/v1.1.1/group.go#L5-L38
It does not limit concurrency, but handles synchronisation to collect
all errors (if any) in a go-multierror.
This patch replaces the go-multierror.Group for a sync.ErrGroup (which
is slightly easier to use, and does allow for limiting concurrency if
wanted), and a basic slice with mutex to collect the errors and to produce
a stdlib multi-error through errors.Join
internal/tracing: replace go-multierror.Group with sync.WaitGroup
The go-multierror Group is just a shallow wrapper around sync.WaitGroup;
https://github.com/hashicorp/go-multierror/blob/v1.1.1/group.go#L5-L38
This patch replaces the go-multierror.Group for a sync.WaitGroup (we
probably don't need to limit concurrency for this one) and stdlib multi-
errors.
pkg/compose: pull: use native multi-errors
What I did
Related issue
(not mandatory) A picture of a cute animal, if possible in relation to what you did