Skip to content

AminN77/morty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

morty

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.

Run 3 nodes (interactive)

Use three terminals and start nodes on these ports:

./morty 1 6000

./morty 2 6001

./morty 3 6002

12-factor configuration

Morty now supports environment-driven config and flag overrides.

Environment variables

  • MORTY_NODE_ID node id (for example 1)
  • MORTY_PORT node port (for example 6000)
  • MORTY_PEERS peer map, format: 1=localhost:6000,2=localhost:6001,3=localhost:6002
  • MORTY_LOG_TARGET one of stdout, stderr, file
  • MORTY_LOG_DIR log directory when MORTY_LOG_TARGET=file
  • MORTY_INTERACTIVE true|false (CLI loop on/off)

Example (service mode)

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

Flags

./morty --node-id 1 --port 6000 --peers "1=localhost:6000,2=localhost:6001,3=localhost:6002" --log-target stdout --interactive false

HTTP KV API

All nodes expose the same API. Writes (/kv/set, /kv/delete) are proposed through Raft.

Set

curl -X POST http://localhost:6000/kv/set \
	-H "Content-Type: application/json" \
	-d '{"key":"item1","value":"tomato"}'

Get

curl "http://localhost:6001/kv/get?key=item1"

Delete

curl -X POST http://localhost:6002/kv/delete \
	-H "Content-Type: application/json" \
	-d '{"key":"item1"}'

Keys

curl "http://localhost:6000/kv/keys"

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages