blob: 644ce7b8f2fdbcdf5569787da874d4774b6151ab [file] [log] [blame]
William Kurkianea869482019-04-09 15:16:11 -04001syntax = "proto2";
2package raftpb;
3
4import "gogoproto/gogo.proto";
5
6option (gogoproto.marshaler_all) = true;
7option (gogoproto.sizer_all) = true;
8option (gogoproto.unmarshaler_all) = true;
9option (gogoproto.goproto_getters_all) = false;
10option (gogoproto.goproto_enum_prefix_all) = false;
11
12enum EntryType {
13 EntryNormal = 0;
14 EntryConfChange = 1;
15}
16
17message Entry {
18 optional uint64 Term = 2 [(gogoproto.nullable) = false]; // must be 64-bit aligned for atomic operations
19 optional uint64 Index = 3 [(gogoproto.nullable) = false]; // must be 64-bit aligned for atomic operations
20 optional EntryType Type = 1 [(gogoproto.nullable) = false];
21 optional bytes Data = 4;
22}
23
24message SnapshotMetadata {
25 optional ConfState conf_state = 1 [(gogoproto.nullable) = false];
26 optional uint64 index = 2 [(gogoproto.nullable) = false];
27 optional uint64 term = 3 [(gogoproto.nullable) = false];
28}
29
30message Snapshot {
31 optional bytes data = 1;
32 optional SnapshotMetadata metadata = 2 [(gogoproto.nullable) = false];
33}
34
35enum MessageType {
36 MsgHup = 0;
37 MsgBeat = 1;
38 MsgProp = 2;
39 MsgApp = 3;
40 MsgAppResp = 4;
41 MsgVote = 5;
42 MsgVoteResp = 6;
43 MsgSnap = 7;
44 MsgHeartbeat = 8;
45 MsgHeartbeatResp = 9;
46 MsgUnreachable = 10;
47 MsgSnapStatus = 11;
48 MsgCheckQuorum = 12;
49 MsgTransferLeader = 13;
50 MsgTimeoutNow = 14;
51 MsgReadIndex = 15;
52 MsgReadIndexResp = 16;
53 MsgPreVote = 17;
54 MsgPreVoteResp = 18;
55}
56
57message Message {
58 optional MessageType type = 1 [(gogoproto.nullable) = false];
59 optional uint64 to = 2 [(gogoproto.nullable) = false];
60 optional uint64 from = 3 [(gogoproto.nullable) = false];
61 optional uint64 term = 4 [(gogoproto.nullable) = false];
62 optional uint64 logTerm = 5 [(gogoproto.nullable) = false];
63 optional uint64 index = 6 [(gogoproto.nullable) = false];
64 repeated Entry entries = 7 [(gogoproto.nullable) = false];
65 optional uint64 commit = 8 [(gogoproto.nullable) = false];
66 optional Snapshot snapshot = 9 [(gogoproto.nullable) = false];
67 optional bool reject = 10 [(gogoproto.nullable) = false];
68 optional uint64 rejectHint = 11 [(gogoproto.nullable) = false];
69 optional bytes context = 12;
70}
71
72message HardState {
73 optional uint64 term = 1 [(gogoproto.nullable) = false];
74 optional uint64 vote = 2 [(gogoproto.nullable) = false];
75 optional uint64 commit = 3 [(gogoproto.nullable) = false];
76}
77
78message ConfState {
79 repeated uint64 nodes = 1;
80 repeated uint64 learners = 2;
81}
82
83enum ConfChangeType {
84 ConfChangeAddNode = 0;
85 ConfChangeRemoveNode = 1;
86 ConfChangeUpdateNode = 2;
87 ConfChangeAddLearnerNode = 3;
88}
89
90message ConfChange {
91 optional uint64 ID = 1 [(gogoproto.nullable) = false];
92 optional ConfChangeType Type = 2 [(gogoproto.nullable) = false];
93 optional uint64 NodeID = 3 [(gogoproto.nullable) = false];
94 optional bytes Context = 4;
95}