Redis Weighted Pool
This is a simple Promise based multi-channel weighted round robin pool implementation that leverages Redis sorted set and list.
You will need Redis server running.
npm install redis-weighted-poolyarn add redis-weighted-pool
The test script in
package.json preprocesses the
.ts file and then executes.
npm run build). You can use in ES5 or later supported environments. The following code snippets are implemented in the
Quick start (Node)
const pool = ;const config = pool;const myPool = config;myPoollength"myChannel";
Optional with existing client
If you already have a program with a
RedisClient you can pass the client as an optional second parameter.
const myPool = null client;myPoollength"myChannel";
Get next peer (weighted round robin)
Remove peer from channel
Reset pool for channel
Check if empty
Get pool length
I haven't thought that far ahead yet. I needed this for my project and wanted to give back. ;-)
MIT (if you enhance it, fork and PR so the community benefits)