loadbalance-middleware

0.0.7 • Public • Published

loadbalance-middleware

A middleware that load balance requests between several other middlewares

npm status Dependency status

example

npm i loadbalance-middleware express

var express = require('express')
var loadbalance = require('loadbalance-middleware')
 
var app = express()
 
function m1(req, res, next) {
    res.end('1')
}
 
function m2(req, res, next) {
    res.end('2')
}
 
app.get('/', loadbalance.roundRobin([m1, m2])) 
 
app.listen(3000, function (err) {
    if (err) return console.error(err)
    console.log('ready')
})

install

With npm do:

npm install loadbalance-middleware

api

loadbalance.random(array)

Creates a middleware that randomly (and evently) distributes requests between the middlewares specified in the provided array

loadbalance.roundRobin(array)

Creates a middleware that distributes requests between the middlewares specified in the provided array in a round robin fashion

loadbalance.engine(engine)

For more custom uses or tweaks, tou can use any engine in loadbalance

see also

loadbalance module

dynamic-middleware module

license

MIT © yaniv kessler

Package Sidebar

Install

npm i loadbalance-middleware

Weekly Downloads

0

Version

0.0.7

License

MIT

Last publish

Collaborators

  • kessler