Skip to content

Commit

Permalink
pr resolves +2=2
Browse files Browse the repository at this point in the history
  • Loading branch information
sainad2222 committed Dec 10, 2024
1 parent 59cab56 commit 7f755a6
Show file tree
Hide file tree
Showing 11 changed files with 1,252 additions and 32 deletions.
18 changes: 10 additions & 8 deletions examples/raft-kv-memstore-grpc/build.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=src/*");
tonic_build::configure().compile_protos(
&[
"proto/internal_service.proto",
"proto/management_service.proto",
"proto/api_service.proto",
],
&["proto"],
)?;
tonic_build::configure()
.type_attribute("openraftpb.Node", "#[derive(Eq, serde::Serialize, serde::Deserialize)]")
.compile_protos(
&[
"proto/internal_service.proto",
"proto/management_service.proto",
"proto/api_service.proto",
],
&["proto"],
)?;
Ok(())
}
17 changes: 8 additions & 9 deletions examples/raft-kv-memstore-grpc/proto/management_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,33 @@ service ManagementService {

// InitRequest contains the initial set of nodes for cluster initialization
message InitRequest {
repeated Node nodes = 1; // List of initial cluster nodes
repeated Node nodes = 1; // List of initial cluster nodes
}

// Node represents a single node in the Raft cluster
message Node {
string rpc_addr = 1; // RPC address for node communication
uint64 node_id = 2; // Unique identifier for the node
string rpc_addr = 1; // RPC address for node communication
uint64 node_id = 2; // Unique identifier for the node
}

// AddLearnerRequest specifies parameters for adding a learner node
message AddLearnerRequest {
Node node = 1; // Node to be added as a learner
bool blocking = 2; // Whether to wait for the operation to complete
Node node = 1; // Node to be added as a learner
}

// RaftRequestString represents a string-based Raft request
message RaftRequestString {
string data = 1; // Request data in string format
string data = 1; // Request data in string format
}

// RaftReplyString represents a string-based Raft response
message RaftReplyString {
string data = 1; // Response data
string error = 2; // Error message, if any
string data = 1; // Response data
string error = 2; // Error message, if any
}

// ChangeMembershipRequest specifies parameters for modifying cluster membership
message ChangeMembershipRequest {
repeated uint64 members = 1; // New set of member node IDs
repeated uint64 members = 1; // New set of member node IDs
bool retain = 2; // Whether to retain existing configuration
}
176 changes: 176 additions & 0 deletions examples/raft-kv-memstore-grpc/rustc-ice-2024-12-10T18_09_47-86281.txt

Large diffs are not rendered by default.

176 changes: 176 additions & 0 deletions examples/raft-kv-memstore-grpc/rustc-ice-2024-12-10T18_09_47-86283.txt

Large diffs are not rendered by default.

176 changes: 176 additions & 0 deletions examples/raft-kv-memstore-grpc/rustc-ice-2024-12-10T18_09_56-86384.txt

Large diffs are not rendered by default.

176 changes: 176 additions & 0 deletions examples/raft-kv-memstore-grpc/rustc-ice-2024-12-10T18_10_07-86478.txt

Large diffs are not rendered by default.

176 changes: 176 additions & 0 deletions examples/raft-kv-memstore-grpc/rustc-ice-2024-12-10T18_11_38-88701.txt

Large diffs are not rendered by default.

176 changes: 176 additions & 0 deletions examples/raft-kv-memstore-grpc/rustc-ice-2024-12-10T18_11_38-88702.txt

Large diffs are not rendered by default.

176 changes: 176 additions & 0 deletions examples/raft-kv-memstore-grpc/rustc-ice-2024-12-10T18_11_46-88800.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl ManagementService for ManagementServiceImpl {

let result = self
.raft_node
.add_learner(node.node_id, raft_node, req.blocking)
.add_learner(node.node_id, raft_node, true)
.await
.map_err(|e| Status::internal(format!("Failed to add learner node: {}", e)))?;

Expand Down
15 changes: 1 addition & 14 deletions examples/raft-kv-memstore-grpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(clippy::uninlined_format_args)]

use std::fmt::Display;

use crate::protobuf::Node;
use crate::store::Request;
use crate::store::Response;

Expand All @@ -25,18 +24,6 @@ pub type LogStore = store::LogStore;
pub type StateMachineStore = store::StateMachineStore;
pub type Raft = openraft::Raft<TypeConfig>;

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, Default)]
pub struct Node {
pub node_id: u64,
pub rpc_addr: String,
}

impl Display for Node {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Node {{ rpc_addr: {}, node_id: {} }}", self.rpc_addr, self.node_id)
}
}

pub mod protobuf {
tonic::include_proto!("openraftpb");
}
Expand Down

0 comments on commit 7f755a6

Please sign in to comment.