Add a utility for doing master election via etcd.

Sending this for comment, will work on unit tests once people are happy with the code.
Ok, I did this.  I'm not 100% certain its more readable, but its your call.  (I have the old copy too, so its easy to restore ;)