raft.proto 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. }
  45. message Message {
  46. optional MessageType type = 1 [(gogoproto.nullable) = false];
  47. optional uint64 to = 2 [(gogoproto.nullable) = false];
  48. optional uint64 from = 3 [(gogoproto.nullable) = false];
  49. optional uint64 term = 4 [(gogoproto.nullable) = false];
  50. optional uint64 logTerm = 5 [(gogoproto.nullable) = false];
  51. optional uint64 index = 6 [(gogoproto.nullable) = false];
  52. repeated Entry entries = 7 [(gogoproto.nullable) = false];
  53. optional uint64 commit = 8 [(gogoproto.nullable) = false];
  54. optional Snapshot snapshot = 9 [(gogoproto.nullable) = false];
  55. optional bool reject = 10 [(gogoproto.nullable) = false];
  56. optional uint64 rejectHint = 11 [(gogoproto.nullable) = false];
  57. }
  58. message HardState {
  59. optional uint64 term = 1 [(gogoproto.nullable) = false];
  60. optional uint64 vote = 2 [(gogoproto.nullable) = false];
  61. optional uint64 commit = 3 [(gogoproto.nullable) = false];
  62. }
  63. message ConfState {
  64. repeated uint64 nodes = 1;
  65. }
  66. enum ConfChangeType {
  67. ConfChangeAddNode = 0;
  68. ConfChangeRemoveNode = 1;
  69. ConfChangeUpdateNode = 2;
  70. }
  71. message ConfChange {
  72. optional uint64 ID = 1 [(gogoproto.nullable) = false];
  73. optional ConfChangeType Type = 2 [(gogoproto.nullable) = false];
  74. optional uint64 NodeID = 3 [(gogoproto.nullable) = false];
  75. optional bytes Context = 4;
  76. }