coreos/etcd — pull request #649 by Ulexus (2014-03-24 17:37:11+00:00)
Title: Implement timeout feature for lock module

This PR implements the timeout feature described but not implemented in the original lock module PR.

As originally described:
* If timeout is undefined (or <0), then timeout is infinite
* If timeout is 0, then the timeout is immediate; if lock is not immediately available, it fails
* If timeout is >0, then if the lock is not acquired withing `timeout` seconds, the lock fails

This necessitated reworking the flow of the acquire handler:
* createNode now _only_ creates the node; it no longer waits on the lock itself.
* getLockIndex (perhaps this is poorly named) extracts out the lock
checking routine so that it can be used by "get" and "watch", both.
* get() was added to instantaneously attempt to acquire a lock with no waiting.

If the lock fails to acquire, for whatever reason, an error is returned, resulting in a code 500 to the client.