-
Notifications
You must be signed in to change notification settings - Fork 0
/
KVService.proto
69 lines (58 loc) · 1.32 KB
/
KVService.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
syntax = "proto3";
option go_package="./KVService";
package KVService;
service Handler {
rpc Put(KV) returns (Response) {}
rpc Get(KV) returns (Response) {}
rpc Delete(KV) returns (Response) {}
rpc GetLeaderID(LeaderID) returns (LeaderID) {}
rpc GetState(State) returns (State) {}
rpc RequestVote(RequestVoteArgs) returns (RequestVoteReply) {}
rpc AppendEntries(AppendEntriesArg) returns (AppendEntriesReply) {}
}
enum OperationType {
PUT = 0;
DELETE = 1;
}
message KV {
bytes Key = 1;
bytes Value = 2;
}
message Response {
string Msg = 1;
KV ReturnKV = 2;
}
message RequestVoteArgs {
int64 Term = 1;
int64 CandidateId = 2;
int64 LastLogIndex = 3;
int64 LastLogTerm = 4;
}
message RequestVoteReply {
int64 Term = 1;
bool VoteGranted = 2;
}
message LogEntry {
OperationType Op = 1;
KV KeyVal = 2;
int64 Term = 3;
int64 ChanId = 4;
}
message AppendEntriesArg {
int64 Term = 1;
int64 LeaderId = 2;
int64 PrevLogIndex = 3;
int64 PrevLogTerm = 4;
repeated LogEntry Entries = 5;
int64 LeaderCommit = 6;
}
message AppendEntriesReply {
int64 Term = 1;
bool Success = 2;
}
message LeaderID {
int64 Id = 1;
}
message State {
int64 state = 1;
}