1.0.0 • Published 5 years ago

request-counting v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

Request-Counting

A node js port for Apache Request Counting Algorithm

Code

import LoadBalance from '../index'

const lb = new LoadBalance()
lb.add('a', 70)
lb.add('b', 30)


let counting = {}
let i = 0
while (i < 10) {
    i++

    let item = lb.pick()
    console.log(item.id, item.status)
    if(counting[item.id] == undefined){
        counting[item.id] = 1
    }else{
        counting[item.id]++
    }
}

console.log(counting)