lytics/metafora — pull request #74 by schmichael (2014-12-02 00:19:25+00:00)
Title: Etcd watching refactor and synchronous main loop

First few files are minor test improvements and a completely useless embedded coordinator bug fix.

Then comes the 2 big changes and a third small one:

1. etcd watching refactor
* :white_check_mark: slightly less code
* :white_check_mark: fewer goroutines
* :white_check_mark: no more watcher state
* :white_check_mark: no more watcher locks
* :x: not as DRY (could probably be tweaked a bit to regain DRYness)
2. main loop "ticks" to make it synchronous. Fixes a problem where coordinator.Watch() would return the same task twice before Claim() would be called. No a huge problem but it caused extra etcd requests and confusing log lines. Has added benefits like not restarting the balancer timer until the previous Balance() call has actually completed.
3. Use wait group for consumer's command, task, and balancer goroutines so Run() and Shutdown() block until all parts of the consumer have exited cleanly.