MCPcopy
hub / github.com/docker/compose / forEachContainerConcurrent

Function forEachContainerConcurrent

pkg/compose/containers.go:181–189  ·  view source on GitHub ↗

forEachContainerConcurrent runs fn for every container concurrently and waits for all goroutines.

(ctx context.Context, containers Containers, fn func(context.Context, container.Summary) error)

Source from the content-addressed store, hash-verified

179
180// forEachContainerConcurrent runs fn for every container concurrently and waits for all goroutines.
181func forEachContainerConcurrent(ctx context.Context, containers Containers, fn func(context.Context, container.Summary) error) error {
182 eg, ctx := errgroup.WithContext(ctx)
183 for _, ctr := range containers {
184 eg.Go(func() error {
185 return fn(ctx, ctr)
186 })
187 }
188 return eg.Wait()
189}
190
191// sorted sorts containers in place by canonical name and returns the (same) slice.
192func (containers Containers) sorted() Containers {

Callers 3

killMethod · 0.85
pauseMethod · 0.85
unPauseMethod · 0.85

Calls 1

WaitMethod · 0.65

Tested by

no test coverage detected