raft.proto 3.0 KB

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