Comments (3)
This will be added shortly, stay tuned.
from bottleneck.
This has been implemented in master and will be released as part of v2.0. I'll let you know when it's released.
Here's what it looks like:
var Bottleneck = require('./lib/bottleneck')
var limiter = new Bottleneck({maxConcurrent: 1, minTime: 500}) // v2 only
var get = function (id, text) {
return new Promise(function (resolve, reject) {
return resolve(`<${id}: ${text}>`)
})
}
var wrapped = limiter.wrap(get)
var t0 = Date.now()
wrapped('abc', 12345)
.then((result) => { console.log(`${Date.now() - t0}ms: DONE ${result}`) })
.catch((err) => { console.log('ERROR!!', err) })
wrapped('def', true)
.then((result) => { console.log(`${Date.now() - t0}ms: DONE ${result}`) })
.catch((err) => { console.log('ERROR!!', err) })
~/dev/bottleneck$ node test.js
6ms: DONE <abc: 12345>
505ms: DONE <def: true>
from bottleneck.
Version 2 has been released, please give it a try. Your feedback is welcome and appreciated!
from bottleneck.
Related Issues (20)
- Using bottleneck options to recover from instance's crash
- Support for node-redis v4
- Invalid job status RECEIVED, expected DONE HOT 1
- task.apply is not a function
- Any correct ways to do rate limit 1000 per hour?
- `light.d.ts` not published in npm package
- Throw error for invalid settings
- Would it be possible to add a reset() method to clear state on local instances? HOT 1
- ReplyError: ERR SETTINGS_KEY_NOT_FOUND when use in Clustering mode with Redis 7.x HOT 8
- Is bottleneck still maintained? HOT 11
- recovering for a crashed service using redis
- bottleneck lost tracing data when using reservoir options
- Redis errors with ReplyError: ERR UNKOWN_CLIENT HOT 7
- dynamic schedule / retry HOT 3
- Long delay in Bottleneck.schedule execution in a distributed env HOT 1
- Is there a way to pass different options for limiters within the same group?
- Is there a way to read and write the reservoir for a given limiter?
- Long-lasting limiters with matching cardinality to app's users
- ERR SETTINGS_KEY_NOT_FOUND with redis 7.0.7 HOT 11
- user_script:201: attempt to compare number with nil
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bottleneck.