This is a dirty implementation of an asynchronous simple task runner that runs tasks concurrently up until a certain limit. I wrote it as part of a live coding interview. Even though I didn't finish it during the live coding session, I still decided to put up the working implementation here.
Your are free to use the code or build upon it.
Node.js is a very cool language in that it runs everything asynchronously using a single event loop so this makes it pretty fast because of its non-blocking IO implementation.
However this asynchronous awesomeness can also be problematic in some situations. For example, you need to process about a million tasks concurrently but only have the computational resource to process just 10000 tasks at a time.
You would definitely want to process a maximum of 10000, but since node.js processes stuff asynchronously, it will end up trying to process all the tasks concurrently and would lead to you running out of resources.
A good way to handle this is to throttle the amount of tasks being processed at any given time, hence the need for a Task Runner like this one.
- Created by Odigie Oseme U. | http://osemeodigie.com [v0.0.1]
Website: http://osemeodigie.com
Make sure you have Node.js installed.
Clone this repo and type:
npm install
npm start
I intend to clean this up, put type validations in place and extend its features. Please feel free to fork this repo and contribute by submitting a pull request to enhance the functionalities.
Hi there,
you can help by staring the github repo 😄 . You can also share the link for this repository on Twitter or HackerNews? I would love the attention 😁 . Help Spread the word!
Don't forget to follow my blog!
Thanks!
Oseme Odigie.
The MIT License (MIT). Please see License File for more information.