-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraft.proto
75 lines (55 loc) · 1.73 KB
/
raft.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// python3 -m grpc_tools.protoc raft.proto --proto_path=. --python_out=. --grpc_python_out=.
syntax = "proto3";
service RaftNode {
rpc RequestVote(VoteRequest) returns (ResultWithTerm) {}
rpc AppendEntries(AppendRequest) returns (ResultWithTerm) {}
rpc GetLeader(EmptyMessage) returns (GetLeaderReply) {}
rpc Suspend(SuspendRequest) returns (EmptyMessage) {}
rpc SetVal(SetRequest) returns (SetReply) {}
rpc GetVal(GetRequest) returns (GetReply) {}
}
message VoteRequest {
int64 term = 1; // Candidate's term.
int64 candidate_id = 2;
int64 last_log_index = 3;
int64 last_log_term = 4;
}
message AppendRequest {
int64 term = 1; // Current term number from the leader
int64 leader_id = 2; // Leader's id. So that the follower knows who his leader is
int64 prev_log_index = 3; // Index of the log entry immediately preceding new ones
int64 prev_log_term = 4; // Term of prev_log_index entry
repeated Entry entries = 5; // Log entries to store (empty for heartbeat)
int64 leader_commit = 6; // Leader's commitIndex
}
message GetLeaderReply {
int64 leader_id = 1;
string address = 2;
}
message SuspendRequest {
int64 period = 1;
}
message SetRequest {
string key = 1;
string value = 2;
}
message SetReply {
bool success = 1;
}
message GetRequest {
string key = 1;
}
message GetReply {
bool success = 1;
string value = 2;
}
message Entry {
int64 term = 1;
string key = 2;
string value = 3;
}
message ResultWithTerm {
int64 term = 1; // Term number of the server
bool result = 2;
}
message EmptyMessage {}