A distributed consensus-based key-value store that replicates data across multiple nodes using a consensus algorithm, ensuring fault tolerance and consistency across the network.
Use three terminals and start nodes on these ports:
./morty 1 6000
./morty 2 6001
./morty 3 6002
Morty now supports environment-driven config and flag overrides.
MORTY_NODE_IDnode id (for example1)MORTY_PORTnode port (for example6000)MORTY_PEERSpeer map, format:1=localhost:6000,2=localhost:6001,3=localhost:6002MORTY_LOG_TARGETone ofstdout,stderr,fileMORTY_LOG_DIRlog directory whenMORTY_LOG_TARGET=fileMORTY_INTERACTIVEtrue|false(CLI loop on/off)
export MORTY_NODE_ID=1
export MORTY_PORT=6000
export MORTY_PEERS="1=localhost:6000,2=localhost:6001,3=localhost:6002"
export MORTY_LOG_TARGET=stdout
export MORTY_INTERACTIVE=false
./morty./morty --node-id 1 --port 6000 --peers "1=localhost:6000,2=localhost:6001,3=localhost:6002" --log-target stdout --interactive falseAll nodes expose the same API. Writes (/kv/set, /kv/delete) are proposed through Raft.
curl -X POST http://localhost:6000/kv/set \
-H "Content-Type: application/json" \
-d '{"key":"item1","value":"tomato"}'curl "http://localhost:6001/kv/get?key=item1"curl -X POST http://localhost:6002/kv/delete \
-H "Content-Type: application/json" \
-d '{"key":"item1"}'curl "http://localhost:6000/kv/keys"