Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darron/sifter
Helps to prevent Consul from firing prematurely.
https://github.com/darron/sifter
Last synced: 3 months ago
JSON representation
Helps to prevent Consul from firing prematurely.
- Host: GitHub
- URL: https://github.com/darron/sifter
- Owner: darron
- License: apache-2.0
- Created: 2015-11-11T01:53:31.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-04T18:36:38.000Z (over 8 years ago)
- Last Synced: 2024-06-20T03:55:38.476Z (5 months ago)
- Language: Go
- Homepage:
- Size: 44.9 KB
- Stars: 72
- Watchers: 8
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-consul - sifter: Helps to prevent Consul from firing prematurely
README
sifter
============[Consul watches](https://www.consul.io/docs/agent/watches.html) act in a bit of a interesting way - when you reload the program - they all fire.
It's a [fairly well known limitation that doesn't have a fix at the moment](https://github.com/hashicorp/consul/issues/571).
If it's a really lightweight process then it's not a big deal - but if it's not so lightweight - then it can be a bit of a problem.
If you take a look at what the watch passes on STDIN during a Consul reload - you will see that if it's not actually firing it just passes:
`[]\n`
So - `sifter` is a small Go binary that helps protect against event watches firing repeatedly:
```
{
"watches": [
{
"type": "event",
"name": "chef-client",
"handler": "sifter run -e 'chef-client'"
}
]
}
```When this gets loaded into Consul - instead of launching copies and copies of `chef-client` processes - which is not awesome I promise - it will just say:
`location='blank' elapsed='226.912µs' exec='chef-client'`
When you actually send the event - the logs will show this - and the event will fire:
```
decoded event='chef-client' ltime='1137'
key='sifter/chef-client/i-c972d41e' value='1137'
location='complete' elapsed='47.448987142s' exec='chef-client'
```Afterwards - if it sees the same event:
`location='duplicate' elapsed='8.269276ms' exec='chef-client'`
## Real World Usage
During a cluster wide rollout of Consul changes - here are a number of events that were prevented from firing because they were duplicate or blank:
![](http://shared.froese.org/2015/cexe8-15-41.jpg)
I only want Consul watches to fire when they're supposed to.
## Development
`brew install forego` if you want to start up Redis and Consul to test.
Have added some watches in the `config/` folder as well as example Consul output - input to sifter in the `test/` folder.