Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ekristen/node-consul-event-cache
Monitor consul events, trigger node event once per event
https://github.com/ekristen/node-consul-event-cache
Last synced: about 2 months ago
JSON representation
Monitor consul events, trigger node event once per event
- Host: GitHub
- URL: https://github.com/ekristen/node-consul-event-cache
- Owner: ekristen
- License: mit
- Created: 2016-01-13T20:57:12.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-14T03:59:53.000Z (almost 8 years ago)
- Last Synced: 2024-10-11T03:19:06.916Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# node-consul-event-cache
[![Build Status](https://travis-ci.org/ekristen/node-consul-event-cache.svg?branch=master)](https://travis-ci.org/ekristen/node-consul-event-cache) [![David](https://img.shields.io/david/ekristen/node-consul-event-cache.svg)]() [![David](https://img.shields.io/david/dev/ekristen/node-consul-event-cache.svg)]() [![npm](https://img.shields.io/npm/v/consul-event-cache.svg)]() [![npm](https://img.shields.io/npm/l/consul-event-cache.svg)]() [![npm](https://img.shields.io/npm/dt/consul-event-cache.svg)]()
This is designed to be used with `node-consul` and the watch command with `consul.event.list` this library turns each event received into an node event, and keeps track so duplicates are not sent.
If multiple events are received with single update, the cache library will trigger 2 separate change events.
## Example
```javascript
var consul = require('consul')()var EventCache = require('consul-event-cache')
var cache = new EventCache()
consul
.watch({
method: consul.event.list
})
.on('error', function(err) {
console.log('error', err)
})
.on('change', cache.update.bind(cache))cache
.on('error', function(err) {
console.log('error', err)
})
.on('change', function(event) {
// a single event
console.log(event)
})
```