/rdoc

a document database based on raft

Primary LanguageGo

A high available document database based on Raft Algorithm, inspired by tiedot and Raft

How to run

Building

  1. install Golang
  2. go build -o rdoc main.go

Running a single node

./rdoc --id 1 --cluster http://127.0.0.1:12379 --port 8080
# each rdoc process is a single raft instance
# id: node ID of this instance, id is incremental and starts from 1.
# cluster: address list of all the nodes in a cluster. In this example, the raft address for node 1 is http://127.0.0.1:12379, so this process will also listen on 12379 for raft request connection.
# port: document database service port.

Running a cluster

Using goreman

goreman is a process manager, it can start multiple instances.

goreman start

This will bring up three rdoc instances.

Starting manually

# start three instances
./rdoc --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 8080
./rdoc --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 8081
./rdoc --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 8082
# this will start three rdoc instances
# the first instance have ID 1, raft service address:http://127.0.0.1:12379, and document database service port 8080;
# the second instance have ID 2, raft service address:http://127.0.0.1:22379, and document database service port 8081;
# the third instance have ID 3, raft service address:http://127.0.0.1:32379, and document database service port 8082;

All three instances can accept CRUD requests, you can use a HTTP proxy for load-balancing.

Add and Delete Node

Adding new node

If you want to add a node to a running cluster, you have to:

./rdoc --id 4 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379,http://127.0.0.1:42379 --port 42380 --join

Removing node