-
Notifications
You must be signed in to change notification settings - Fork 1
/
raft.proto
94 lines (78 loc) · 1.63 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
syntax = "proto3";
package raftpb;
message LastVoted {
string votedFor = 1;
uint64 votedTerm = 2;
}
message RequestVoteReq {
uint64 term = 1;
uint64 lastLogIndex = 2;
uint64 lastLogTerm = 3;
string candidateID = 4;
}
message RequestVoteResp {
uint64 term = 1;
bool voteGranted = 2;
}
message LogEntry {
uint64 term = 1;
uint64 index = 2;
bytes data = 3;
enum LogType {
LogCommand = 0;
LogNoop = 1;
LogConf = 2;
}
LogType logType = 4;
}
message AppendEntriesReq {
uint64 term = 1;
string leaderID = 2;
uint64 prevLogIndex = 3;
uint64 prevLogTerm = 4;
uint64 leaderCommitIndex = 6;
repeated LogEntry entries = 5;
}
message AppendEntriesResp {
uint64 term = 1;
bool success = 2;
uint64 lastLogIndex = 3;
}
message InstallSnapshotReq {
uint64 term = 1;
string leaderID = 2;
uint64 lastIndex = 3;
uint64 lastTerm = 4;
uint64 offset = 5;
bytes data = 6;
bool done = 7;
}
message InstallSnapshotResp {
uint64 term = 1;
bool success = 2;
}
enum NodeRole {
Voter = 0;
}
message ConfChange {
enum Type {
AddNode = 0;
RemoveNode = 1;
}
Type type = 1;
NodeRole role = 2;
string serverID = 3;
}
message Node {
NodeRole role = 1;
string serverID = 2;
}
message Configuration {
uint64 index = 1;
repeated Node nodes = 2;
}
service RaftService {
rpc RequestVote (RequestVoteReq) returns (RequestVoteResp);
rpc AppendEntries (AppendEntriesReq) returns (AppendEntriesResp);
rpc InstallSnapshot (InstallSnapshotReq) returns (InstallSnapshotResp);
}