Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions examples/memstore/src/client/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use raftify::{
create_client, raft_service, AbstractLogEntry
};
use raftify::{create_client, raft_service, AbstractLogEntry};

use memstore_example_harness::state_machine::LogEntry;

Expand Down Expand Up @@ -32,7 +30,12 @@ async fn main() {
println!("Peers: {:?}", peers.into_inner().peers_json);

println!("---Debug node result---");
let result = leader_client.debug_node(raft_service::Empty {}).await.unwrap().into_inner().result_json;
let result = leader_client
.debug_node(raft_service::Empty {})
.await
.unwrap()
.into_inner()
.result_json;

println!("Debug node result: {:?}", result);

Expand Down Expand Up @@ -68,5 +71,4 @@ async fn main() {
// },
// ],
// }).await.expect("Change config failed!");

}
5 changes: 5 additions & 0 deletions raftify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ description.workspace = true
keywords.workspace = true
readme = "../README.md"

[features]
default = ["inspection_api", "manipulation_api"]
inspection_api = []
manipulation_api = []

[dependencies]
async-trait = "0.1.48"
bincode = "1.3"
Expand Down
9 changes: 8 additions & 1 deletion raftify/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.build_client(true)
.build_server(true)
.extern_path(".eraftpb", "::jopemachine_raft::eraftpb")
.compile(&["proto/raft_service.proto"], &["proto/"])?;
.compile(
&[
"proto/raft_service.proto",
"proto/raft_inspection_service.proto",
"proto/raft_manipulation_service.proto",
],
&["proto/"],
)?;

built::write_built_file().expect("Failed to acquire build-time information");
Ok(())
Expand Down
48 changes: 48 additions & 0 deletions raftify/proto/raft_inspection_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
syntax = "proto3";
package raft_inspection_service;

import "eraftpb.proto";

// TODO: Implement each methods
service RaftInspectionService {
rpc GetPendingConfChange(Empty) returns (Empty) {}
rpc GetSnapshotReport(Empty) returns (Empty) {}
rpc GetPeers(Empty) returns (Empty) {}

// Progress
rpc GetProgressMatched(Empty) returns (Empty) {}
rpc GetProgressNextIdx(Empty) returns (Empty) {}
rpc GetProgressPaused(Empty) returns (Empty) {}
rpc GetProgressPendingSnapshot(Empty) returns (Empty) {}
rpc GetProgressPendingRequestSnapshot(Empty) returns (Empty) {}
rpc GetProgressRecentActive(Empty) returns (Empty) {}
rpc GetProgressCommitGroupId(Empty) returns (Empty) {}
rpc GetProgressInflights(Empty) returns (Empty) {}
rpc GetProgressState(Empty) returns (Empty) {}

rpc GetNodeId(Empty) returns (Empty) {}
rpc GetLeaderId(Empty) returns (Empty) {}
rpc GetTerm(Empty) returns (Empty) {}

// HardState
rpc GetHardStateTerm(Empty) returns (Empty) {}
rpc GetHardStateVote(Empty) returns (Empty) {}
rpc GetHardStateCommit(Empty) returns (Empty) {}

// ConfState
rpc GetConfStateVoters(Empty) returns (Empty) {}
rpc GetConfStateLearners(Empty) returns (Empty) {}
rpc GetConfStateVotersOutgoing(Empty) returns (Empty) {}
rpc GetConfStateLearnersNext(Empty) returns (Empty) {}
rpc GetConfStateSnapshot(Empty) returns (Empty) {}
rpc GetConfStateLastIndex(Empty) returns (Empty) {}

// RaftLog
rpc GetRaftLogCommitted(Empty) returns (Empty) {}
rpc GetRaftLogApplied(Empty) returns (Empty) {}
rpc GetRaftLogPersisted(Empty) returns (Empty) {}
}

// Common

message Empty {}
26 changes: 26 additions & 0 deletions raftify/proto/raft_manipulation_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";
package raft_manipulation_service;

import "eraftpb.proto";

// TODO: Implement each methods
service RaftManipulationService {
rpc Campaign(Empty) returns (Empty) {}
rpc TransferLeader(Empty) returns (Empty) {}
rpc AbortTransferLeader(Empty) returns (Empty) {}
rpc Ping(Empty) returns (Empty) {}
rpc BecomeFollower(Empty) returns (Empty) {}
rpc BecomeLeader(Empty) returns (Empty) {}
rpc BecomeCandidate(Empty) returns (Empty) {}
rpc BecomePreCandidate(Empty) returns (Empty) {}
rpc RequestSnapshot(Empty) returns (Empty) {}
rpc CreateSnapshot(Empty) returns (Empty) {}
rpc IsPromotable(Empty) returns (Empty) {}
rpc CheckQuorumActive(Empty) returns (Empty) {}
rpc SendTimeoutNow(Empty) returns (Empty) {}
rpc Reset(Empty) returns (Empty) {}
}

// Common

message Empty {}
2 changes: 1 addition & 1 deletion raftify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ pub use crate::{
raft_client::create_client,
raft_node::{role::InitialRole, RaftNode},
raft_service::raft_service_client::RaftServiceClient,
request::common::confchange_request::ConfChangeRequest,
state_machine::AbstractStateMachine,
storage::heed_storage::HeedStorage,
storage::StableStorage,
request::common::confchange_request::ConfChangeRequest,
};

pub(crate) use crate::utils::macros::macro_utils;
Loading