code: func StatBlobsParallelHelper(ctx context.Context, blobs []blob.Ref, fn func(blob.SizedRef) error,
  	gate *syncutil.Gate, worker func(blob.Ref) (blob.SizedRef, error)) error {
  	if len(blobs) == 0 {
  		return nil
  	}
  
  	ctx, cancel := context.WithCancel(ctx)
  	defer cancel()
  
  	var fnMu sync.Mutex // serializes calls to fn
  
  	var wg syncutil.Group
  	for i := range blobs {
  		gate.Start()
  		b := blobs[i]
  
  		select {
  		case <-ctx.Done():
  			// If a previous failed, stop.
  			break
  		default:
  		}
  
  		wg.Go(func() error {
  			defer gate.Done()
  
  			sb, err := worker(b)
  			if err != nil {
  				cancel()
  				return err
  			}
  			if !sb.Valid() {
  				// not found.
  				return nil
  			}
  
  			fnMu.Lock()
  			defer fnMu.Unlock()
  
  			select {
  			case <-ctx.Done():
  				// If a previous failed, stop.
  				return ctx.Err()
  			default:
  			}
  
  			if err := fn(sb); err != nil {
  				cancel() // stop others from running
  				return err
  			}
  			return nil
  		})
  	}
  
  	if err := wg.Err(); err != nil {
  		return err
  	}
  	select {
  	case <-ctx.Done():
  		return ctx.Err()
  	default:
  		return nil
  	}
  }
docs: // StatBlobsParallelHelper is for use by blobserver implementations
  // that want to issue stats in parallel.  This runs worker in multiple
  // goroutines (bounded by gate), but calls fn in serial, per the
  // BlobStatter contract, and stops once there's a failure.
  //
  // The worker func should return two zero values to signal that a blob
  // doesn't exist. (This is different than the StatBlob func, which
  // returns os.ErrNotExist)