0.1.2 • Published 11 years ago
load-manager v0.1.2
Load Manager
Lightweight load manager for node.js-powered APIs. Executes a range callbacks as an instance's load rises and falls. Load based on API calls, not server CPU load.
Install
npm install load-manager
Usage
TODO Working example
As this is a lightweight module, we'll use restify for our server in preference to express. Start by requiring and instantiate the modules.
api = require('restify').createServer()
loadManager = require('load-manager')()
Start the server.
api.listen 8080, ->
console.log 'listening at %s', api.url
Load must be recorded manually. This can be achieved most simply as part of some middleware.
api.pre (req, res, next) ->
loadManager.increment()
But it can also be weighted and associated with individal resources and methods.
api.put '/test', (req, res, next) ->
loadManager.increment 5
TODO Finish usage