Skip to content

Commit

Permalink
Merge branch 'main' of github.com:spacewalkhq/raft-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhawvipul committed Sep 9, 2024
2 parents a29df04 + 159a18e commit c77a663
Show file tree
Hide file tree
Showing 9 changed files with 625 additions and 31 deletions.
2 changes: 1 addition & 1 deletion examples/simple_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn main() {
let id = cluster_nodes[i];
let cc = cluster_config.clone();
handles.push(tokio::spawn(async move {
let mut server = Server::new(id, config, cc).await;
let mut server = Server::new(id, config, cc, None).await;
server.start().await;
}));
}
Expand Down
4 changes: 2 additions & 2 deletions examples/simulate_add_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async fn main() {
let id = cluster_nodes[i];
let cc = cluster_config.clone();
handles.push(tokio::spawn(async move {
let mut server = Server::new(id, config, cc).await;
let mut server = Server::new(id, config, cc, None).await;
server.start().await;
}));
}
Expand All @@ -64,7 +64,7 @@ async fn main() {

// Launching a new node
handles.push(tokio::spawn(async move {
let mut server = Server::new(new_node_id, new_node_conf, cluster_config).await;
let mut server = Server::new(new_node_id, new_node_conf, cluster_config, None).await;
server.start().await;
}));

Expand Down
5 changes: 3 additions & 2 deletions examples/simulate_node_failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn main() {
let id = cluster_nodes[i];
let cc = cluster_config.clone();
let server_handle = tokio::spawn(async move {
let mut server = Server::new(id, config, cc).await;
let mut server = Server::new(id, config, cc, None).await;
server.start().await;
});
server_handles.push(server_handle);
Expand Down Expand Up @@ -77,7 +77,8 @@ async fn main() {
};
let cc = cluster_config.clone();
let server_handle = tokio::spawn(async move {
let mut server = Server::new(server_to_stop.try_into().unwrap(), config, cc).await;
let mut server =
Server::new(server_to_stop.try_into().unwrap(), config, cc, None).await;
server.start().await;
});
server_handles[server_to_stop - 1] = server_handle;
Expand Down
5 changes: 3 additions & 2 deletions examples/simulate_replica_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async fn main() {
warn!(get_logger(), "Storage for server {} is corrupted", id);
}

let mut server = Server::new(id, config, cc).await;
let mut server = Server::new(id, config, cc, None).await;
server.start().await;
});
server_handles.push(server_handle);
Expand Down Expand Up @@ -98,7 +98,8 @@ async fn main() {
leadership_preferences: HashMap::new(),
storage_location: Some(storage_path.clone()),
};
let mut server = Server::new(server_to_fail.try_into().unwrap(), config, cc).await;
let mut server =
Server::new(server_to_fail.try_into().unwrap(), config, cc, None).await;
server.start().await;
// Handle recovery of corrupted storage
info!(
Expand Down
5 changes: 5 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pub enum Error {
/// Some other error occurred.
#[error("unknown error {0}")]
Unknown(#[from] Box<dyn std::error::Error + Sync + Send>),
/// To handle all bincode error
#[error("Bincode error {0}")]
BincodeError(#[from] bincode::Error),
}

#[derive(Error, Debug)]
Expand All @@ -39,6 +42,8 @@ pub enum NetworkError {

#[derive(Error, Debug)]
pub enum StorageError {
#[error("Path not found")]
PathNotFound,
#[error("File is empty")]
EmptyFile,
#[error("File is corrupted")]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pub mod error;
pub mod log;
pub mod network;
pub mod server;
pub mod state_mechine;
pub mod storage;
2 changes: 1 addition & 1 deletion src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl NetworkLayer for TCPManager {
join_all(futures)
.await
.into_iter()
.collect::<std::result::Result<_, _>>()
.collect::<Result<Vec<()>>>()
// FIXME: We should let client decide what to do with the errors
.map_err(|e| NetworkError::BroadcastError(e.to_string()))?;
Ok(())
Expand Down
Loading

0 comments on commit c77a663

Please sign in to comment.