nikestep/grunt-html-angular-validate — pull request #9 by chriskuehl (2014-08-08 19:43:24+00:00)
Title: Add support for concurrently validating files

Howdy there!

First, thanks for an awesome Grunt task! We're using this on the Rackspace Cloud Intelligence team as part of the test process on our build server, and it's been working great for us.

One issue we've had is that validation is performed one file at a time. Our project has hundreds of views to validate, so it takes ~2.5 minutes to run a full validation.

We've found that we can speed this up greatly by validating a files in parallel; when testing against a beefy 32-core HTML validation server with 32 concurrent jobs, it takes less than 5 seconds to check the entire project (versus 2.5 minutes in serial).

I've modified your task to allow parallel execution. It uses the awesome (and tiny) [async](https://github.com/caolan/async) library to validate files in parallel with a configurable concurrency limit. I've made a couple minor changes to the code to keep the complexity low:
* Switching out the home-baked linked-list implementation for arrays, which means we can use standard functional approaches to concurrency (like `map`). This also makes some other parts of the code simpler.
* Removed `validate` function side effects so that we can safely run it in parallel; it returns its result (success boolean). These get counted to provide the `succeedCount` to `finished`.

There's one functionality change, which is that if validation fails more than the allowed number of times, it now stops attempting to validate the remaining views. In our experience, validation usually fails when the validation server blocks you for too many requests, and you then have to wait a long time for the rest of the views to also fail, further bombarding the server. I'm happy to revert this change if you don't like it.

Would love to work with you to help get this merged! Cheers!