promise-pool 1.0.0
Install from the command line:
Learn more about npm packages
$ npm install @elite-libs/promise-pool@1.0.0
Install via package.json:
"@elite-libs/promise-pool": "1.0.0"
About this version
A background task processor focused on reliability and scalability.
- [x] Configurable.
- [x] Concurrency limit.
- [x] Retries. (Use
p-retry
for this.) - [x] Zero dependencies.
- [x] Error handling.
- [ ] Singleton mode: Option to Auto-reset when
.done()
. - [x] Task scheduling & prioritization.
- [x] Optionally
return
hints. (To support API's like GitHub which return rate limit hints in http headers, e.g.X-RateLimit-Remaining
header.)
- [x] Optionally
PromisePool
exposes 2 methods: .add(...tasks)
and .done()
. This is to make it easy to implement & operate.
Tasks added to the pool will begin executing immediately, with a concurrency limit as configured (default of 4
).
# with npm
npm install @elite-libs/promise-pool
# or using yarn
yarn add @elite-libs/promise-pool
import PromisePool from '@elite-libs/promise-pool';
// 1/3: Either use the default instance or create a new one.
const pool = new PromisePool();
// 2/3: Add task(s) to the pool as needed.
// PromisePool will execute them in parallel as soon as possible.
pool.add(() => saveToS3(data));
pool.add(() => expensiveBackgroundWork(data));
// 3/3: REQUIRED: in order to ensure your tasks are executed,
// you must call `await pool.done()` at the end of your script.
await pool.done();
Details
- promise-pool
- elite-libs
- over 2 years ago
- BSD-3-Clause
- 15 dependencies
Assets
- promise-pool-1.0.0-npm.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0