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.
Thanks for splitting this up, it's MUCH more understandable now.

I feel bad asking for more changes, but it seems like this function and becomeMaster would both be improved by returning a bool and not a string?