/
pfs.proto
395 lines (332 loc) · 9.73 KB
/
pfs.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
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
syntax = "proto3";
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "client/pkg/shard/shard.proto";
package pfs;
message Repo {
string name = 1;
}
message Commit {
Repo repo = 1;
string id = 2;
}
message File {
Commit commit = 1;
string path = 2;
}
message Block {
string hash = 1;
}
message Diff {
Commit commit = 1;
uint64 shard = 2;
}
message RepoInfo {
Repo repo = 1;
google.protobuf.Timestamp created = 2;
uint64 size_bytes = 3;
repeated Repo provenance = 4;
}
message RepoInfos {
repeated RepoInfo repo_info = 1;
}
enum CommitType {
COMMIT_TYPE_NONE = 0;
COMMIT_TYPE_READ = 1;
COMMIT_TYPE_WRITE = 2;
}
message CommitInfo {
Commit commit = 1;
string branch = 2;
CommitType commit_type = 3;
Commit parent_commit = 4;
google.protobuf.Timestamp started = 5;
google.protobuf.Timestamp finished = 6;
uint64 size_bytes = 7;
bool cancelled = 8;
repeated Commit provenance = 9;
}
message CommitInfos {
repeated CommitInfo commit_info = 1;
}
enum FileType {
FILE_TYPE_NONE = 0;
FILE_TYPE_REGULAR = 1;
FILE_TYPE_DIR = 2;
}
message FileInfo {
File file = 1;
FileType file_type = 2;
uint64 size_bytes = 3;
google.protobuf.Timestamp modified = 4;
Commit commit_modified = 5;
repeated File children = 6;
}
message FileInfos {
repeated FileInfo file_info = 1;
}
message ByteRange {
uint64 lower = 1;
uint64 upper = 2;
}
message BlockRef {
Block block = 1;
ByteRange range = 2;
}
message BlockRefs {
repeated BlockRef block_ref = 1;
}
message Append {
repeated BlockRef block_refs = 1;
map<string, bool> children = 2;
Commit last_ref = 3;
bool delete = 4;
map<string, BlockRefs> handles = 5;
map<string, bool> handle_deletes = 6;
FileType file_type = 7;
}
message BlockInfo {
Block block = 1;
google.protobuf.Timestamp created = 2;
uint64 size_bytes = 3;
}
message BlockInfos {
repeated BlockInfo block_info = 1;
}
message DiffInfo {
Diff diff = 1;
Commit parent_commit = 2;
string branch = 3;
google.protobuf.Timestamp started = 4;
google.protobuf.Timestamp finished = 5;
// Appends is the BlockRefs which have been append to files indexed by path.
map<string, Append> appends = 6;
uint64 size_bytes = 7;
bool cancelled = 8;
repeated Commit provenance = 9;
}
message Shard {
uint64 file_number = 1;
uint64 file_modulus = 2;
uint64 block_number = 3;
uint64 block_modulus = 4;
}
message CreateRepoRequest {
Repo repo = 1;
google.protobuf.Timestamp created = 2;
repeated Repo provenance = 3;
}
message InspectRepoRequest {
Repo repo = 1;
}
message ListRepoRequest {
repeated Repo provenance = 1;
}
message DeleteRepoRequest {
Repo repo = 1;
bool force = 2;
}
message StartCommitRequest {
Repo repo = 1;
string id = 2;
string parent_id = 3;
string branch = 4;
google.protobuf.Timestamp started = 5;
repeated Commit provenance = 6;
}
message FinishCommitRequest {
Commit commit = 1;
bool cancel = 2;
google.protobuf.Timestamp finished = 3;
}
message InspectCommitRequest {
Commit commit = 1;
}
message ListCommitRequest {
repeated Repo repo = 1;
CommitType commit_type = 2;
repeated Commit from_commit = 3;
repeated Commit provenance = 4;
bool all = 5;
bool block = 6;
}
message ListBranchRequest {
Repo repo = 1;
}
message DeleteCommitRequest {
Commit commit = 1;
}
message FlushCommitRequest {
repeated Commit commit = 1;
repeated Repo to_repo = 2;
}
// DiffMethod specifies how file operations represent changes to files.
// If FromCommit is nil then the whole file will be returned.
// If FromCommit is not nil and FullFile is false then only the changes since
// FromCommit will be returned.
// If FromCommit is not nil and FullFile is true then the whole file will be
// returned if there have been changes since FromCommit.
message DiffMethod {
Commit from_commit = 1;
bool full_file = 2;
}
message GetFileRequest {
File file = 1;
int64 offset_bytes = 2;
int64 size_bytes = 3;
Shard shard = 4;
DiffMethod diff_method = 5;
bool unsafe = 7;
string handle = 8;
}
enum Delimiter {
NONE = 0;
JSON = 1;
LINE = 2;
}
message PutFileRequest {
File file = 1;
FileType file_type = 2;
bytes value = 3;
string handle = 4;
Delimiter delimiter = 5;
}
message InspectFileRequest {
File file = 1;
Shard shard = 2;
DiffMethod diff_method = 3;
bool unsafe = 4;
string handle = 5;
}
message ListFileRequest {
File file = 1;
Shard shard = 2;
DiffMethod diff_method = 3;
bool recurse = 4;
bool unsafe = 5;
string handle = 6;
}
message DeleteFileRequest {
File file = 1;
bool unsafe = 2;
string handle = 3;
}
service API {
// Repo rpcs
// CreateRepo creates a new repo.
// An error is returned if the repo already exists.
rpc CreateRepo(CreateRepoRequest) returns (google.protobuf.Empty) {}
// InspectRepo returns info about a repo.
rpc InspectRepo(InspectRepoRequest) returns (RepoInfo) {}
// ListRepo returns info about all repos.
rpc ListRepo(ListRepoRequest) returns (RepoInfos) {}
// DeleteRepo deletes a repo.
rpc DeleteRepo(DeleteRepoRequest) returns (google.protobuf.Empty) {}
// Commit rpcs
// StartCommit creates a new write commit from a parent commit.
rpc StartCommit(StartCommitRequest) returns (Commit) {}
// FinishCommit turns a write commit into a read commit.
rpc FinishCommit(FinishCommitRequest) returns (google.protobuf.Empty) {}
// InspectCommit returns the info about a commit.
rpc InspectCommit(InspectCommitRequest) returns (CommitInfo) {}
// ListCommit returns info about all commits.
rpc ListCommit(ListCommitRequest) returns (CommitInfos) {}
// DeleteCommit deletes a commit.
rpc DeleteCommit(DeleteCommitRequest) returns (google.protobuf.Empty) {}
// FlushCommit waits for downstream commits to finish
rpc FlushCommit(FlushCommitRequest) returns (CommitInfos) {}
// ListBranch returns info about the heads of branches.
rpc ListBranch(ListBranchRequest) returns (CommitInfos) {}
// File rpcs
// PutFile writes the specified file to pfs.
rpc PutFile(stream PutFileRequest) returns (google.protobuf.Empty) {}
// GetFile returns a byte stream of the contents of the file.
rpc GetFile(GetFileRequest) returns (stream google.protobuf.BytesValue) {}
// InspectFile returns info about a file.
rpc InspectFile(InspectFileRequest) returns (FileInfo) {}
// ListFile returns info about all files.
rpc ListFile(ListFileRequest) returns (FileInfos) {}
// DeleteFile deletes a file.
rpc DeleteFile(DeleteFileRequest) returns (google.protobuf.Empty) {}
// DeleteAll deletes everything
rpc DeleteAll(google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
service InternalAPI {
// Repo rpcs
// CreateRepo creates a new repo.
// An error is returned if the repo already exists.
rpc CreateRepo(CreateRepoRequest) returns (google.protobuf.Empty) {}
// InspectRepo returns info about a repo.
rpc InspectRepo(InspectRepoRequest) returns (RepoInfo) {}
// ListRepo returns info about all repos.
rpc ListRepo(ListRepoRequest) returns (RepoInfos) {}
// DeleteRepo deletes a repo.
rpc DeleteRepo(DeleteRepoRequest) returns (google.protobuf.Empty) {}
// Commit rpcs
// StartCommit creates a new write commit from a parent commit.
rpc StartCommit(StartCommitRequest) returns (google.protobuf.Empty) {}
// FinishCommit turns a write commit into a read commit.
rpc FinishCommit(FinishCommitRequest) returns (google.protobuf.Empty) {}
// InspectCommit returns the info about a commit.
rpc InspectCommit(InspectCommitRequest) returns (CommitInfo) {}
// ListCommit returns info about all commits.
rpc ListCommit(ListCommitRequest) returns (CommitInfos) {}
// DeleteCommit deletes a commit.
rpc DeleteCommit(DeleteCommitRequest) returns (google.protobuf.Empty) {}
// FlushCommit waits for downstream commits to finish
rpc FlushCommit(FlushCommitRequest) returns (CommitInfos) {}
// ListBranch returns info about the heads of branches.
rpc ListBranch(ListBranchRequest) returns (CommitInfos) {}
// File rpcs
// PutFile writes the specified file to pfs.
rpc PutFile(stream PutFileRequest) returns (google.protobuf.Empty) {}
// GetFile returns a byte stream of the contents of the file.
rpc GetFile(GetFileRequest) returns (stream google.protobuf.BytesValue) {}
// InspectFile returns info about a file.
rpc InspectFile(InspectFileRequest) returns (FileInfo) {}
// ListFile returns info about all files.
rpc ListFile(ListFileRequest) returns (FileInfos) {}
// DeleteFile deletes a file.
rpc DeleteFile(DeleteFileRequest) returns (google.protobuf.Empty) {}
// DeleteAll deletes everything
rpc DeleteAll(google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
message PutBlockRequest {
bytes value = 1;
Delimiter delimiter = 2;
}
message GetBlockRequest {
Block block = 1;
uint64 offset_bytes = 2;
uint64 size_bytes = 3;
}
message DeleteBlockRequest {
Block block = 1;
}
message InspectBlockRequest {
Block block = 1;
}
message ListBlockRequest {
}
message InspectDiffRequest {
Diff diff = 1;
}
message ListDiffRequest {
uint64 shard = 1;
}
message DeleteDiffRequest {
Diff diff = 1;
}
service BlockAPI {
rpc PutBlock(stream PutBlockRequest) returns (BlockRefs) {}
rpc GetBlock(GetBlockRequest) returns (stream google.protobuf.BytesValue) {}
rpc DeleteBlock(DeleteBlockRequest) returns (google.protobuf.Empty) {}
rpc InspectBlock(InspectBlockRequest) returns (BlockInfo) {}
rpc ListBlock(ListBlockRequest) returns (BlockInfos) {}
rpc CreateDiff(DiffInfo) returns (google.protobuf.Empty) {}
rpc InspectDiff(InspectDiffRequest) returns (DiffInfo) {}
rpc ListDiff(ListDiffRequest) returns (stream DiffInfo) {}
rpc DeleteDiff(DeleteDiffRequest) returns (google.protobuf.Empty) {}
}