Exemplo n.º 1
0
func (s *Service) eachContainer(ctx context.Context, containers []*container.Container, action func(*container.Container) error) error {

	tasks := utils.InParallel{}
	for _, cont := range containers {
		task := func(cont *container.Container) func() error {
			return func() error {
				return action(cont)
			}
		}(cont)

		tasks.Add(task)
	}

	return tasks.Wait()
}
Exemplo n.º 2
0
func (s *Service) eachContainer(action func(*Container) error) error {
	containers, err := s.collectContainers()
	if err != nil {
		return err
	}

	tasks := utils.InParallel{}
	for _, container := range containers {
		task := func(container *Container) func() error {
			return func() error {
				return action(container)
			}
		}(container)

		tasks.Add(task)
	}

	return tasks.Wait()
}