cockroachdb/cockroach — pull request #150 by spencerkimball (2014-10-28 17:38:58+00:00)
Title: Move KV client interface to client package.

Mother of all code reviews -- sorry. Matt, I'd like you to pay careful
attention to all of it. Everyone else, this is mostly refactoring
and includes some code movement, so isn't as bad as it looks.

Created a new client interface which does away with strongly-typed
methods for each KV API call. Instead, use a method string and args
proto.Request and reply proto.Response. The client is pretty well
described by client/doc.go. In essence there's an interface for
quick, synchronous usage via the Call() method. and an interface
for easily doing parallel queries and updates via the Prepare() and
Flush() methods.

The KV client sends its requests using the client.KVSender interface.
When a Go application uses Cockroach via the client package, the
KVSender will be an instance of client.httpSender, which sends calls
over HTTP as application/x-protobuf. When Cockroach nodes access
Cockroach via the client package, the KVSender is an instance of
kv.DistSender. Most unittests use kv.LocalSender.

Moved client transactional logic from kv/txn_db.go to client/txn_sender.go.
The logic for restarting the transactional retryable block is in
client/kv.go in client.KV.RunTransaction.

Added a Key Value DB interface to the HTTP server. The REST interface
is now at /kv/rest/. The DB interface is at /kv/db/. The KV DB server
looks at the HTTP path for the method and invokes it using an instance
of the node's DistSender. The DB interface at /kv/db/ only serves
public methods, not internal methods.

Still TODO: unittests for client/txn_sender and client/kv. Will send
these as the next commit for this PR.