Skip to content
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

Run imports in parallel #340

Merged
merged 1 commit into from
Oct 4, 2022
Merged

Conversation

ArthurSens
Copy link
Contributor

Fixes #329

@ArthurSens ArthurSens requested a review from a team October 3, 2022 19:56
func runImports(kImports []importer.KustomizeImporter, yImports []importer.YAMLImporter) (imports []string, err error) {
errc := make(chan error)
defer close(errc)
var errWg sync.WaitGroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The x sync library has better groups for this: https://pkg.go.dev/golang.org/x/sync/errgroup

We should be able to make these loops with this errgroup package instead, waiting on the whole group. Hopefully, this should make the logic a bit simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I wasn't aware of this package! Let me try :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed code looks a lot cleaner!

Signed-off-by: ArthurSens <arthursens2005@gmail.com>
@ArthurSens ArthurSens force-pushed the arthursens/run-imports-in-parallel-329 branch from 9ac240b to a426b9f Compare October 4, 2022 14:34
Copy link
Contributor

@liam-j-bennett liam-j-bennett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@ArthurSens ArthurSens merged commit cb8a680 into main Oct 4, 2022
@ArthurSens ArthurSens deleted the arthursens/run-imports-in-parallel-329 branch October 4, 2022 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run imports in parallel
2 participants