-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkvraft.proto
executable file
·71 lines (61 loc) · 1.23 KB
/
kvraft.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
syntax = "proto3";
import "google/protobuf/wrappers.proto";
package kvraft;
message Operation{
enum OpName{
GET = 0;
PUT = 1;
DEL = 2;
}
int32 index = 1;
OpName op = 2;
string key = 3;
string value = 4;
}
enum KVResult{
OK = 0;
ErrNoKey = 1;
ErrTimeout = 2;
ErrWrongLeader = 3;
}
message KVArgs{
Operation command = 1;
int32 clientid = 2;
int32 seq = 3;
}
message KVReply{
KVResult res = 1;
string value = 2;
}
message LogEntry{
Operation command = 1;
int32 term = 2;
}
message RequestVoteArgs{
int32 term = 1;
int32 candidateid = 2;
int32 lastlogindex = 3;
int32 lastlogterm = 4;
}
message RequestVoteReply{
int32 term = 1;
bool votegranted = 2;
}
message AppendEntriesArgs{
int32 term = 1;
int32 leaderid = 2;
int32 prevlogindex = 3;
int32 prevlogterm = 4;
int32 leadercommit = 5;
repeated LogEntry entries = 6;
}
message AppendEntriesReply{
int32 term = 1;
bool success = 2;
int32 replicatedindex = 3;
}
service KVRaft{
rpc RequestVote(RequestVoteArgs) returns (RequestVoteReply);
rpc AppendEntries(AppendEntriesArgs) returns (AppendEntriesReply);
rpc Command(KVArgs) returns (KVReply);
}