coreos/etcd — pull request #398 by benbjohnson (2013-12-13 22:36:53+00:00)
Title: mod/leader

## Overview

This pull request includes the Leader Election module. It allows users to come to consensus on a single value by wrapping the mod/lock interface with a simpler "value-only" interface.

## API

To use mod/leader, have one or more potential leaders set their value:

```sh
$ curl -X POST http://localhost:4001/mod/v2/leader?ttl=5 -d name=myserver1
```

The first client will obtain leadership while the other clients will wait until the leader disconnects manually or the TTL expires. The leader can continue to hold leadership by sending the same `POST` request to push back the TTL.

The leader can disconnect manually using a `DELETE` request:

```sh
$ curl -X DELETE http://localhost:4001/mod/v2/leader?name=myserver1
```

To obtain the current leader value, simply use a `GET` request:

```sh
$ curl http://localhost:4001/mod/v2/leader/foo
myserver1
```

/cc @philips @xiangli-cmu