forked from whispem/minikv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkv.proto
More file actions
218 lines (175 loc) · 3.92 KB
/
Copy pathkv.proto
File metadata and controls
218 lines (175 loc) · 3.92 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
syntax = "proto3";
package minikv;
// Internal volume service (coordinator → volume)
service VolumeInternal {
// 2PC write protocol
rpc Prepare(PrepareRequest) returns (PrepareResponse);
rpc Commit(CommitRequest) returns (CommitResponse);
rpc Abort(AbortRequest) returns (AbortResponse);
// Replication & repair
rpc Pull(PullRequest) returns (stream Chunk);
rpc Delete(DeleteRequest) returns (DeleteResponse);
// Health & admin
rpc Ping(PingRequest) returns (PingResponse);
rpc Stats(StatsRequest) returns (StatsResponse);
}
// Coordinator service (volume → coordinator, raft peers)
service CoordinatorInternal {
// Raft RPCs
rpc RequestVote(VoteRequest) returns (VoteResponse);
rpc AppendEntries(AppendRequest) returns (AppendResponse);
rpc InstallSnapshot(SnapshotRequest) returns (SnapshotResponse);
// Volume registration
rpc Join(JoinRequest) returns (JoinResponse);
rpc Heartbeat(HeartbeatRequest) returns (HeartbeatResponse);
// Range queries and batch operations
rpc Range(RangeRequest) returns (RangeResponse);
rpc Batch(BatchRequest) returns (BatchResponse);
}
// ===== Range Query Messages =====
message RangeRequest {
string start = 1;
string end = 2;
bool include_values = 3;
}
message RangeResponse {
repeated string keys = 1;
repeated bytes values = 2;
}
// ===== Batch Operation Messages =====
message BatchRequest {
repeated BatchOp ops = 1;
}
message BatchOp {
enum Type {
PUT = 0;
GET = 1;
DELETE = 2;
}
Type type = 1;
string key = 2;
bytes value = 3;
}
message BatchResponse {
repeated BatchResult results = 1;
}
message BatchResult {
bool ok = 1;
string key = 2;
bytes value = 3;
string error = 4;
}
// ===== 2PC Messages =====
message PrepareRequest {
string key = 1;
string upload_id = 2;
uint64 expected_size = 3;
string expected_blake3 = 4;
}
message PrepareResponse {
bool ok = 1;
string error = 2;
}
message CommitRequest {
string upload_id = 1;
string key = 2;
}
message CommitResponse {
bool ok = 1;
string error = 2;
}
message AbortRequest {
string upload_id = 1;
}
message AbortResponse {
bool ok = 1;
}
// ===== Replication Messages =====
message PullRequest {
string key = 1;
string source_url = 2;
}
message Chunk {
bytes data = 1;
}
message DeleteRequest {
string key = 1;
}
message DeleteResponse {
bool ok = 1;
string error = 2;
}
// ===== Health Messages =====
message PingRequest {}
message PingResponse {
string volume_id = 1;
uint64 uptime_secs = 2;
uint64 total_keys = 3;
uint64 total_bytes = 4;
}
message StatsRequest {}
message StatsResponse {
uint64 total_keys = 1;
uint64 total_bytes = 2;
uint64 free_bytes = 3;
repeated string shards = 4;
}
// ===== Raft Messages =====
message VoteRequest {
uint64 term = 1;
string candidate_id = 2;
uint64 last_log_index = 3;
uint64 last_log_term = 4;
}
message VoteResponse {
uint64 term = 1;
bool vote_granted = 2;
}
message AppendRequest {
uint64 term = 1;
string leader_id = 2;
uint64 prev_log_index = 3;
uint64 prev_log_term = 4;
repeated LogEntry entries = 5;
uint64 leader_commit = 6;
}
message AppendResponse {
uint64 term = 1;
bool success = 2;
uint64 conflict_index = 3;
}
message SnapshotRequest {
uint64 term = 1;
string leader_id = 2;
uint64 last_included_index = 3;
uint64 last_included_term = 4;
bytes data = 5;
}
message SnapshotResponse {
uint64 term = 1;
}
message LogEntry {
uint64 term = 1;
uint64 index = 2;
bytes data = 3;
}
// ===== Coordinator Messages =====
message JoinRequest {
string volume_id = 1;
string address = 2;
repeated string shards = 3;
}
message JoinResponse {
bool ok = 1;
string cluster_id = 2;
}
message HeartbeatRequest {
string volume_id = 1;
uint64 total_keys = 2;
uint64 total_bytes = 3;
uint64 free_bytes = 4;
}
message HeartbeatResponse {
bool ok = 1;
repeated string commands = 2; // e.g., ["compact_shard:0", "rebalance"]
}