Crates.io | remote_hash_map |
lib.rs | remote_hash_map |
version | 0.2.6 |
source | src |
created_at | 2024-06-16 11:32:36.506236 |
updated_at | 2024-06-27 21:04:54.436735 |
description | Remote hash map |
homepage | |
repository | https://github.com/kwdowicz/remote_hash_map |
max_upload_size | |
id | 1273464 |
size | 88,383 |
A distributed node cluster management system using gRPC, implementing a replicated key-value store.
The system consists of two main components:
Clone the repository:
git clone https://github.com/kwdowicz/remote_hash_map.git
cd remote_hash_map
Build the project:
cargo build --release
Start the NodeGroup service:
./target/release/ng --listen 127.0.0.1:5000
Run nodes and connect them to the NodeGroup:
./target/release/node --listen 127.0.0.1:6001 --ng 127.0.0.1:5000
./target/release/node --listen 127.0.0.1:6002 --ng 127.0.0.1:5000
Create a new project:
mkdir rhm_test && cd rhm_test
cargo init
cargo add remote_hash_map tokio
Add the following to src/main.rs
:
use remote_hash_map::common::client::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = Client::connect("127.0.0.1:5000").await?;
client.set("name", "Daria").await?;
client.set("name", "Tosia").await?;
client.set("name", "Gabi").await?;
let result = client.get("name").await?;
println!("Name: {}", result);
Ok(())
}
Run the client:
cargo run
grpcurl -plaintext -d '{"key": "name", "value": "Tas", "replication": true }' 127.0.0.1:5021 node_rpc.NodeRpc/Set
grpcurl -plaintext -d '{}' 127.0.0.1:5000 node_group_rpc.NodeGroupRpc/GetServer
Build and run using Docker:
docker build -t remote_hash_map .
docker network create --subnet=192.168.0.0/16 my_network
docker run --name ng --network my_network --ip 192.168.0.3 remote_hash_map ng
docker run --name node --network my_network --ip 192.168.0.4 -e NG_ADDRESS="192.168.0.3:5000" remote_hash_map node
./target/release/ng --listen 127.0.0.1:5000 --ping-sec 4
The project uses env_logger
. Set the RUST_LOG
environment variable for different log levels:
RUST_LOG=debug ./target/release/node --listen 127.0.0.1:6001 --ng 127.0.0.1:5000
Contributions are welcome! Please submit a pull request or open an issue to discuss proposed changes or improvements.
This project is licensed under the MIT License.