I want to have a pool of workers completing multiple jobs with rate-limiting / concurrency, but because there are a lot of jobs, and each job description can take up a big chunk of memory, I would like to only create the job "on-the-fly" as soon as a worker slot is ready. Is that easy to do with p-queue ?
For instance a "solution" like that Promise.all(myHugeListOfJobs) would not work because it would require creating all the tasks at once and fill up the memory.
For now I use async-sema with a semaphore, and a util like this:
I want to have a pool of workers completing multiple jobs with rate-limiting / concurrency, but because there are a lot of jobs, and each job description can take up a big chunk of memory, I would like to only create the job "on-the-fly" as soon as a worker slot is ready. Is that easy to do with p-queue ?
For instance a "solution" like that
Promise.all(myHugeListOfJobs)
would not work because it would require creating all the tasks at once and fill up the memory.For now I use
async-sema
with a semaphore, and a util like this:that I use like this