GithubHelp home page GithubHelp logo

cbonello / kv-store Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 37 KB

A basic key-value database to experiment with gRPC, protocol buffers and programming language interoperability (Golang, Node.Js and Python).

License: MIT License

Go 29.16% Makefile 3.95% JavaScript 29.79% Python 37.10%
golang python nodejs grpc protocol-buffers key-value-store kv-store

kv-store's Introduction

KV-STORE

A small key-value database to play with gRPC, protocol buffers and programming language interoperability.

The database can be replicated on multiple servers that implement a basic eventual consistency model using the RegisterWithPeer() and Set() rpc methods (see file kv.proto):

  1. When a new server is started, it performs a RegisterWithPeer() rpc call for each peer IP listed on the command line. Peers respond with the contents of their key-value store.

  2. When a key-value is created/updated, a server broadcast the update to its peer(s).

Current implementation restricts Keys and values to alphanumeric characters and underscores. Both a client and a server are provided and implemented with Google Go, Node.js and Python.

Repository was only tested on Linux and is using GNU make features.

Installation

make install
make build

Usage

To demonstrate the servers functionnalities, let's start a few of them.

Server

Go server

$ go run go/main.go server -v
Listening on 127.0.0.1:4000...

Note: Default IP address and port number used by servers and clients is "127.0.0.1:4000".

Node.js server

$ node node/index.js server --ip 127.0.0.1:4001 -v 127.0.0.1:4000
1543334553169: registering with peer 127.0.0.1:4000...
Listening on 127.0.0.1:4001...

Python server

$ python python/server.py --ip 127.0.0.1:4002 -v 127.0.0.1:4000 127.0.0.1:4001
2018-11-27 11:08:08: registering with peer 127.0.0.1:4000...
2018-11-27 11:08:08: registering with peer 127.0.0.1:4001...
Listening on 127.0.0.1:4002...

Client

$ python python/client.py --set a=b --list -v
2018-11-27 11:26:42: sending SET request to 127.0.0.1:4000 for key 'a'...
2018-11-27 11:26:42: sending LIST request to 127.0.0.1:4000...
Key-value pairs defined on 127.0.0.1:4000:
  - 'a'='b'
-- end of key-value dump --
$ go run go/main.go client --ip 127.0.0.1:4001 --list
Key-value pairs defined on 127.0.0.1:4001:
  - 'a'='b'
-- end of key-value dump --
$ node node/index.js client --ip 127.0.0.1:4002 --list -v
1543335852521: sending LIST request to 127.0.0.1:4002...
Key-value pairs defined on 127.0.0.1:4002:
 - 'a'='b'
-- end of key-value dump --

TODO

  1. Add unit tests.
  2. Handle network errors.

kv-store's People

Contributors

cbonello avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.