Added new protobuf message structures, changed existing ones and renamed
Application to suit better terminologies.

Renamed Application to ZMQApp and zmq_transport.application to zmq_transport.app. And zmq_application to zmq_app.

Refactored zmq_app.ZMQApp.__init__ to maintain backwards compatibility.

Added a small todo in zmq_server to send client an error msg if it doesnt recognize the request. For now it silently ignores the request.

Fixed typo in application_runner.

Modified protobuf messages. Added protobuf utilites and tests.

Added ClientInfo message type for storing client and request information.
Feature: Squashed commits that restructure the message flow. Now
messages are parsed on the application tier instead of the server tier.
The server tier just acts as a middle agent now.

Changed protobuf message ClientInfo from string to type byte.

Refactored server side for sending received messages from client to the application instead of parsing them.

Wrapped line under 79 chars in zmq_base.

Completed app-server-client communication wrt sync.

Added server_state module from u1db trunk.

Removed queue. Queuing messages directly on the socket itself.

Added sync module from u1db trunk.
Feature: Squashed commits that implement SyncResource. Not really a
resource. But maintaining the same name for easier follow up. Also added
u1db application logic for get_sync_info, sync_exchange and record_sync_info.

Added SyncResource class and response methods for handlers to get_sync_info_request and put_sync_info_request.

Added doc strings.

Added user_id to every message struct.

Fixed tests to comply with changes in protobuf message structs.

Added target_last_known_generation and target_last_known_trans_id to protobuf request messages. Also added tests for the changes.

Added last_known_target_generation and last_known_target_trans_id to AllSentRequest message. Modified tests accordingly.

Fixed import statement.

Fixed numbering of protobuf message fields.

Added source_replia_uid to AllSentRequest message. Modified tests accordingly.

Added u1db application logic to execute get_sync_info on the application side, insert docs from source and find changes to return to source, send docs changed at target to source and record_sync_info.
Review Fixes: Squashed all minor commits related to review comments.
Note: Not yet fixed the following:

1. Convert handle_all_sent_request.get_docs_to_send to an inline code.
2. Check if last doc received from source was successfully inserted
   before sending docs changed at target to source.

Removed blank line from import statement.

Renamed instance variables to make them private in SyncResource.

Fixed documentation by increasing clarity.

Added todo to remove ensure in the long run from instantiate_requirements.

Fixed minor typos.

Optimized creation of docs_by_gen.

Added irc logs as comments instead of pointing to the url.

Moved out u1db trunk files into project root. Now using u1db.remote for unchanged u1db source. Chagned source will now extend the default u1db implementation and live in zmq_transport.u1db

Forgot to add u1db.backends

Added helper utility to access private variable _db in SyncExchange extension at zmq_transport.u1db.sync

Added todo about doing some logging after application tier has sent a message.

Added return_list decorator. It typecasts the return value of the function being decorated to a list. Used this to typecast return values of message handlers to a list. Used decorator as it feels more agile and beautiful. Note: Learned decorators today. Will use everywhere possible from now on. But with good judgement. :P

Renamed _prepare_u1db_aciton to _prepare_u1db_sync_resource. Name feels more related.

Renamed instantiate_requirements to prepare_for_sync_exchange. Again, name feels more related to the task it is doing. :)

Fixed minor bug in handle_put_sync_info_request. Param db was wrongly set.

Removed redundant find_changes_to_return operation in return_changed_docs. This is already force done during the PING-ACK.

Added doc_rev to SendDocumentRequest. Modified tests accordingly.

Fixed minor typos.
Squashed commits from first shot on bug fixes, code cleanups, minor additions.

Added helper methods to set, release and check user_id in zmq_target.

Fixed typo in calling _prepare_u1db_action.

Removed local U1DB trunk files. Now installed as a dependency.

Fixed database opening issues. Now, u1db can open a database based off a user_id, provided that database is already present.

Updated requirements.txt

Fixed data being packed into message structures.

Changed type of doc_rev to string. Modified tests accordingly.

Added workaround to find out last_known generation and trans_id before validating them in prepare_for_sync_exchange.

Fixed bugs in sync. Current BUG is that target returns the doc just received from source.
Squashed commits from second shot on bug fixes, code cleanups, minor
additions to get sync working. One bug exists: Target returns the docs
just inserted as part of docs changed at target.

Added try-except to handle InvalidTransactionID in prepare_for_sync_exchange.

Removed unnecessary ZMQVerb and SyncType messages in get_sync_info and some code cleanup.

Removed code withing function get_docs_to_send and made it as inline code.

Changed return_list decorator to handle None type returns. Application now recovers from errors to serve further requests. But the client hangs in limbo. Recommend to add an ErrorMessage in protobuf.

Added target_gen and target_trans_id info in SendDocumentResponse message. Modified tests accordingly.

Fixed typo in utils.

Code cleanup + Bug hunting. Bug is still elusive.

Updated .gitignore
Squashed minor commits to fix InvalidTransactionId error in zmq_app.

Fixed bug in return_list decorator.

Minor silly errors. Fixed them.

Fixed bug in send docs changed at source to target within sync_exchange.

Fixed bug causing InvalidTransactionId error on sending the second changed doc from source to target.
Working Sync Process: Squashed bug fixes and redesigning of
GetSyncInfoRequest-Response cycle.

BUG Fix: Fixed bug of target sending the just inserted docs as part of docs changed at target.

BUG FIX: Fixed GetSyncInforResponse. But problem in flow exists. Blocking REQ on client can't accept more than one response. Thus ignores everything after the first doc.

Updated message structs for redesigned GetDocumentRequest-Response cycle.

Minor bug fix in storing seen_ids. Now only storing the seen_id if the doc is successsfully inserted.

Implemented cache at application tier to store changed documents. Completed redesign of GetDocumentRequest-Response cycle.

Remvoed caching system. Instead target stores no information about changed docs. As requested by the source, they are fetched in place. More efficient than caching. Saves a lot of memory.

Fixed message structure creation in record_sync_info step.
Updated requirements.txt
Merge branch 'zmq_app'