Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shakyshane/heartbeat-monitor
Keep track of items via heartbeats
https://github.com/shakyshane/heartbeat-monitor
Last synced: about 1 month ago
JSON representation
Keep track of items via heartbeats
- Host: GitHub
- URL: https://github.com/shakyshane/heartbeat-monitor
- Owner: shakyShane
- License: mit
- Created: 2014-02-12T08:50:34.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-08-20T10:48:20.000Z (over 10 years ago)
- Last Synced: 2024-04-14T07:49:48.518Z (9 months ago)
- Language: JavaScript
- Size: 148 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# heartbeat-monitor [![Build Status](https://travis-ci.org/shakyShane/heartbeat-monitor.png?branch=master)](https://travis-ci.org/shakyShane/heartbeat-monitor)
Keep track of a collection of items that emit heartbeats. Think tracking connected clients with socket.io
## Usage
Install it locally to your project.`sudo npm install -g heartbeat-monitor`
## Example
This example shows how you can track an array of items. It will check the registry for any items
that have not emitted a heartbeat in the last second & remove the outdated ones. If you've ever
tried to keep track of socket-connected clients with something like socket.io, you'll understand the
need for this module.```javascript
var monitor = require("heartbeat-monitor");
var registry = [];monitor.watchRegistry(registry, 1000).on("item:add", function(){
// Item added
}).on("item:removed", function(){
// Item removed
}).on("item:updated", function(){
// Item updated
});// Imitate a reaction to a heartbeat every 800ms - adding it to the registry
setInterval(function(){
monitor.addItem({id: 123});
}, 800);```
**Note:** This was written to keep track of connected clients with [BrowserSync](https://github.com/shakyShane/browser-sync)
- not tested at any kind of scale yet.## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).## Release History
_(Nothing yet)_## License
Copyright (c) 2013 Shane Osbourne
Licensed under the MIT license.