Rust. Like many developers, I could not pass on the opportunity of learning more about the Rust programming language. As an engineer in the security field, and as a developer that was first introduced to the world of programming through C, Rust’s memory safety features are inspiring.
In order to get a better understanding of Rust and its internals, myself and two colleagues decided to implement a replicated key-value store in Rust as our first projects.
Granted, we could’ve chosen a simpler project, however, it wouldn’t be as fun, would it?
You can take a look at the result of the project by visiting https://github.com/himalayadb/himalayadb. For the project, we used RocksDB as our persistence layer, and etcd as our distributed metadata store.
To get started, fire up 3 nodes:
cargo run --bin himalayadb -- -i node1 -r 2 -t -3074457345618258603 --port 50051 --etcd_host localhost --etcd_port 2379 --rocksdb_path /tmp/node1 cargo run --bin himalayadb -- -i node2 -r 2 -t -9223372036854775808 --port 50052 --etcd_host localhost --etcd_port 2379 --rocksdb_path /tmp/node2 cargo run --bin himalayadb -- -i node3 -r 2 -t 3074457345618258602 --port 50053 --etcd_host localhost --etcd_port 2379 --rocksdb_path /tmp/node3
The parameters are as follow:
-iis the node identifier
-ris the replication factor
-tis the node token (used for consistent hashing)
Once services are up, you can simply use the key-value store as follow:
cargo run --bin himalaya-client -- --host localhost --port 50051 write -k k1 -v v1