Crates.io | railyard |
lib.rs | railyard |
version | 0.0.1 |
source | src |
created_at | 2024-05-06 01:42:29.146592 |
updated_at | 2024-05-06 01:42:29.146592 |
description | Railyard is an implementation of the Raft concensus algorithm using Tonic |
homepage | |
repository | https://github.com/emersonmde/railyard |
max_upload_size | |
id | 1230694 |
size | 36,914 |
Railyard is an implementation of the Raft concensus algorithm using the Tonic gRPC framework. This project aims to provide a reusable foundation for building distributed systems that require high availability and fault tolerance.
⚠️ Warning: Experimental ⚠️
Railyard is currently in early development. It should not be used in production systems as it has not been tested and may still undergo significant changes and improvements.
To incorporate Railyard into your project, add it as a dependency in your Cargo.toml:
[dependencies]
railyard = "0.1.0"
Initialize and run a Railyard cluster by including it in your Rust application:
use railyard::Railyard;
#[tokio::main]
async fn main() {
let my_cluster = Railyard::new_server("node_id", vec!["peer1:port", "peer2:port"]).await;
my_cluster.run().await;
}
For detailed examples and usage, see the examples directory and refer to the API documentation.
To run the server example locally, set the port and at least 2 other peers:
cd examples/server
cargo run -- -p 8001 --peer 127.0.0.1:8002 --peer 127.0.0.1:8002 --peer 127.0.0.1:8003 &
cargo run -- -p 8002 --peer 127.0.0.1:8002 --peer 127.0.0.1:8001 --peer 127.0.0.1:8003 &
cargo run -- -p 8003 --peer 127.0.0.1:8002 --peer 127.0.0.1:8001 --peer 127.0.0.1:8002 &
To aid in spinning up a cluster, the examples/server
directory contains a
start_cluster.sh
script that will start a cluster with 3 nodes:
./examples/server/start_cluster.sh
To run the server using Docker Compose:
docker-compose up
This will startup a cluster with 3 nodes by default and automatically configure the peers to listen on port 8000.
Once the cluster is running the API can be tested with grpcurl
:
grpcurl -plaintext -import-path ./proto -proto cluster_management.proto -d '{"entries": ["test"]}' '[::1]:8001' railyard.ClusterManagement/AppendEntries
This project is licensed under the MIT license.