// ParallelCancelOnError runs the given functions in parallel, cancelling all if one fails.
//
// It collects all the errors in the returned error. To obtain
// the multiple errors, use the `Errors` function.
ParallelCancelOnError runs the given functions in parallel, cancelling all if one fails.

It collects all the errors in the returned error. To obtain
the multiple errors, use the `Errors` function.
// ParallelCancelOnError runs the given functions in parallel cancelling all if one fails . // // It collects all the errors in the returned error . To obtain // the multiple errors use the ` Errors ` function .
func (f *Flow) ParallelCancelOnError(ctx context.Context, fns ...Func) error {
	if len(fns) == 0 {
		return nil
	}
	ctx, cancel := context.WithCancel(ctx)
	defer cancel()
	results := make(chan error)
	f.runAll(len(fns), func(i int) {
		err := fns[i](ctx)
		results <- err
	}, func() { close(results) })
	var errs multiError
	for err := range results {
		if err != nil {
			cancel()
			errs = append(errs, err)
		}
	}
	return errs.ErrorOrNil()
}
func ( f * Flow ) ParallelCancelOnError ( ctx context . Context , fns ... Func ) error { if len ( fns ) == 0 { return nil } ctx , cancel := context . WithCancel ( ctx ) defer cancel ( ) results := make ( chan error ) f . runAll ( len ( fns ) , func ( i int ) { err := fns [ i ] ( ctx ) results <- err } , func ( ) { close ( results ) } ) var errs multiError for err := range results { if err != nil { cancel ( ) errs = append ( errs , err ) } } return errs . ErrorOrNil ( ) }
ParallelCancelOnError runs the given functions in parallel, cancelling all if one fails.
ParallelCancelOnError runs the given functions in parallel cancelling all if one fails .