Scott Baker | eee8dd8 | 2019-09-24 12:52:34 -0700 | [diff] [blame] | 1 | syntax = "proto2"; |
| 2 | package raftpb; |
| 3 | |
| 4 | import "gogoproto/gogo.proto"; |
| 5 | |
| 6 | option (gogoproto.marshaler_all) = true; |
| 7 | option (gogoproto.sizer_all) = true; |
| 8 | option (gogoproto.unmarshaler_all) = true; |
| 9 | option (gogoproto.goproto_getters_all) = false; |
| 10 | option (gogoproto.goproto_enum_prefix_all) = false; |
| 11 | |
| 12 | enum EntryType { |
| 13 | EntryNormal = 0; |
| 14 | EntryConfChange = 1; |
| 15 | } |
| 16 | |
| 17 | message 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 | |
| 24 | message 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 | |
| 30 | message Snapshot { |
| 31 | optional bytes data = 1; |
| 32 | optional SnapshotMetadata metadata = 2 [(gogoproto.nullable) = false]; |
| 33 | } |
| 34 | |
| 35 | enum 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 | |
| 57 | message 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 | |
| 72 | message 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 | |
| 78 | message ConfState { |
| 79 | repeated uint64 nodes = 1; |
| 80 | repeated uint64 learners = 2; |
| 81 | } |
| 82 | |
| 83 | enum ConfChangeType { |
| 84 | ConfChangeAddNode = 0; |
| 85 | ConfChangeRemoveNode = 1; |
| 86 | ConfChangeUpdateNode = 2; |
| 87 | ConfChangeAddLearnerNode = 3; |
| 88 | } |
| 89 | |
| 90 | message 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 | } |