sequential-task-queue icon indicating copy to clipboard operation
sequential-task-queue copied to clipboard

Max Size

Open ftaiolivista opened this issue 7 years ago • 4 comments

Hi.

Would be great to have the posibility to set a maxsize for the queue

ftaiolivista avatar Mar 09 '17 08:03 ftaiolivista

Any idea of what should happen when maxSize is exceeded? I think push should throw an Error in this case, because the error event is used to notify of errors thrown in a running task. Another option is to return a Promise that is immediately rejected, and report the rejection in an error event.

BalassaMarton avatar Mar 09 '17 10:03 BalassaMarton

hm.. I think that it can simply throw an exception. Because it's not an async check but you know if the size is in overflow immedialty at push time. One can manage the event with a try/catch around the push. You can mimci this extension https://github.com/cnwhy/promise-queue-plus I's a good extension but I have prefered your for lighter dedendencies.

ftaiolivista avatar Mar 09 '17 10:03 ftaiolivista

I don't think Promise Queue Plus supports this at all. It has an option to set the maximum concurrent tasks, but as far as I can tell from the source, it doesn't have an option to limit queue length.

BalassaMarton avatar Mar 09 '17 11:03 BalassaMarton

you are right... my mistake. The max queue size is implemented in this lib https://github.com/azproduction/promise-queue

ftaiolivista avatar Mar 09 '17 11:03 ftaiolivista