From 030d8edbd3ddecdc60ba7f62512a14abc59b0dd7 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Thu, 18 Aug 2016 19:40:53 +0200 Subject: [PATCH 1/5] Update README.md --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ba7300..e70952d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,54 @@ -# P2S -peer to peer sync using low level languages +# Peer2Sync + +Peer to server syncronization using c++ high performance web server with a redis backend through JSON-RPC 2.0 requests. The code is contained in a docker container to simplify the deployment. + +## Deployment + +Download the container from the docker-hub +``` +docker pull kanekotic/p2s +``` + +And execute with the next command +``` +docker run -p -e PORT= -e REDIS_IP= -e REDIS_PORT= --net=host kanekotic/p2s +``` + +## Development + +Current development enviroment is based on un an Ubuntu machine. Please follow the next steps to setup the enviroment: + +- Basic building will require the next packages +``` +sudo apt-get install redis-server libboost-all-dev gcc-5 g++-5 libgtest-dev cmake qt5-qmake qt5-default qtbase5-dev qttools5-dev-tools +``` +- To build gtest run +``` +cd /usr/src/gtest +sudo cmake . +sudo cmake --build . +sudo mv libg* /usr/local/lib/ +``` +- you will also need to pull the dependency for the redis client trought +``` +git clone https://github.com/Cylix/cpp_redis.git +cd cpp_redis +mkdir build +cd build +cmake .. +make -j +sudo make install -j +sudo cp /usr/local/lib/libcpp_redis.so /usr/lib/libcpp_redis.so +``` +- the code can be build using the next command line on the directory +``` +qmake +make +``` +**optional** + +- Use ```Qt Creator``` as development enviroment, it can be installed by: +``` +sudo apt-get install qtcreator +``` +- Install and use Postman for integration testing (```./test/Test_P2S_Postman.json```). From 0f4093c536ad2adb998b3e418eeeddf284f53ba6 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Thu, 18 Aug 2016 19:43:11 +0200 Subject: [PATCH 2/5] Update README.md --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e70952d..bd34b38 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,16 @@ # Peer2Sync -Peer to server syncronization using c++ high performance web server with a redis backend through JSON-RPC 2.0 requests. The code is contained in a docker container to simplify the deployment. +Peer to server syncronization using c++ high performance web server with a redis backend. + +The path to requests is /rpc and takes only POST requests in JSON-RPC 2.0. + +The purpose of this route would be to implement a simple protocol capable of P2P (master to master) syncing key-value datastores. + +The JSON-RPC methods that have to be implemented to cover the sync protocol are: +datastorePut({ collection: String, changes: [Object] }) -> returns error or nothing +datastoreGet({ collection: String, all: Boolean, ids: [String] }) -> returns array of objects +datastoreMeta({ collection: String }) -> returns array of tuples [object id, object mtime] for all objects of the collection + ## Deployment From 8c2ae2d70056df8e5ad4bc8a36bff72d94ae0cd0 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Thu, 18 Aug 2016 19:54:46 +0200 Subject: [PATCH 3/5] Update README.md --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bd34b38..c522036 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,20 @@ # Peer2Sync -Peer to server syncronization using c++ high performance web server with a redis backend. +##Intro -The path to requests is /rpc and takes only POST requests in JSON-RPC 2.0. - -The purpose of this route would be to implement a simple protocol capable of P2P (master to master) syncing key-value datastores. - -The JSON-RPC methods that have to be implemented to cover the sync protocol are: -datastorePut({ collection: String, changes: [Object] }) -> returns error or nothing -datastoreGet({ collection: String, all: Boolean, ids: [String] }) -> returns array of objects -datastoreMeta({ collection: String }) -> returns array of tuples [object id, object mtime] for all objects of the collection +Protocol capable of P2P (master to master) syncing key-value datastores. using ```c++``` high performance web server with a redis backend. The path to requests is ```/rpc``` and takes only ```POST``` requests in ```JSON-RPC 2.0```. The methods that have been implemented are: +- ```datastorePut({ collection: String, changes: [Object] }) -> ```: sync objects to the server. +- ```datastoreGet({ collection: String, all: Boolean, ids: [String] }) -> [Object]```: retrieve all of the objects which are newer on the server. +- ```datastoreMeta({ collection: String }) -> [id,mtime]```: get last modification times of all objects upstream. +Arguments explanation: +- ```collection```: this is a string identifier of the collection we want to sync. +- ```changes```: this is an array of objects to save in the collection; every object can be anything (JSON object). Has three special properties: + - ```_id```: (always required) is the object key/id. + - ```_mtime```: is the last time the object was modified. + - ```_delete```: is set to true if we want to remove this object from the collection. +- ```all```: this is a boolean which, when set to true, makes datastoreGet return all objects in the collection +- ```ids```: array of strings, required when we don’t pass { all: true } to datastoreGet: specifies which objects to fetch from the database. ## Deployment From 56de63e3a85c52d286ab165f2700ea0469a5eec8 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Thu, 18 Aug 2016 19:57:46 +0200 Subject: [PATCH 4/5] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c522036..99c18b9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,10 @@ Arguments explanation: - ```_mtime```: is the last time the object was modified. - ```_delete```: is set to true if we want to remove this object from the collection. - ```all```: this is a boolean which, when set to true, makes datastoreGet return all objects in the collection -- ```ids```: array of strings, required when we don’t pass { all: true } to datastoreGet: specifies which objects to fetch from the database. +- ```ids```: array of strings, specifies which objects to fetch from the database. + +The implementation is integrated in Travis-CI, that will generate and publish automatically containers to easy deploy the application. + ## Deployment From b2cc2a9de1edf75bd54a1e85f0b538947fa29cbc Mon Sep 17 00:00:00 2001 From: Alvaro Date: Thu, 18 Aug 2016 20:04:23 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99c18b9..110fdc4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Peer2Sync +# ![logomakr_0ewpnu](https://cloud.githubusercontent.com/assets/3071208/17784932/e2b96a14-657e-11e6-9cf9-ad0000e3e18c.png) ##Intro