networkdb.proto 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. syntax = "proto3";
  2. import "gogoproto/gogo.proto";
  3. package networkdb;
  4. option (gogoproto.marshaler_all) = true;
  5. option (gogoproto.unmarshaler_all) = true;
  6. option (gogoproto.stringer_all) = true;
  7. option (gogoproto.gostring_all) = true;
  8. option (gogoproto.sizer_all) = true;
  9. option (gogoproto.goproto_stringer_all) = false;
  10. // MessageType enum defines all the core message types that networkdb
  11. // uses to communicate to peers.
  12. enum MessageType {
  13. option (gogoproto.goproto_enum_prefix) = false;
  14. option (gogoproto.enum_customname) = "MessageType";
  15. INVALID = 0 [(gogoproto.enumvalue_customname) = "MessageTypeInvalid"];
  16. // NetworEvent message type is used to communicate network
  17. // attachments on the node.
  18. NETWORK_EVENT = 1 [(gogoproto.enumvalue_customname) = "MessageTypeNetworkEvent"];
  19. // TableEvent message type is used to communicate any table
  20. // CRUD event that happened on the node.
  21. TABLE_EVENT = 2 [(gogoproto.enumvalue_customname) = "MessageTypeTableEvent"];
  22. // PushPull message type is used to syncup all network
  23. // attachments on a peer node either during startup of this
  24. // node or with a random peer node periodically thereafter.
  25. PUSH_PULL = 3 [(gogoproto.enumvalue_customname) = "MessageTypePushPull"];
  26. // BulkSync message is used to bulksync the whole networkdb
  27. // state with a peer node during startup of this node or with
  28. // a random peer node periodically thereafter.
  29. BULK_SYNC = 4 [(gogoproto.enumvalue_customname) = "MessageTypeBulkSync"];
  30. // Compound message type is used to form a compound message
  31. // which is a pack of many message of above types, packed into
  32. // a single compound message.
  33. COMPOUND = 5 [(gogoproto.enumvalue_customname) = "MessageTypeCompound"];
  34. // NodeEvent message type is used to communicare node
  35. // join/leave events in the cluster
  36. NODE_EVENT = 6 [(gogoproto.enumvalue_customname) = "MessageTypeNodeEvent"];
  37. }
  38. // GossipMessage is a basic message header used by all messages types.
  39. message GossipMessage {
  40. MessageType type = 1; // type defines one of the message types defined above.
  41. bytes data = 2; // Payload of the message of any type defined here.
  42. }
  43. // NodeEvent message payload definition.
  44. message NodeEvent {
  45. enum Type {
  46. option (gogoproto.goproto_enum_prefix) = false;
  47. option (gogoproto.enum_customname) = "Type";
  48. INVALID = 0 [(gogoproto.enumvalue_customname) = "NodeEventTypeInvalid"];
  49. // Join event is generated when this node joins the cluster.
  50. JOIN = 1 [(gogoproto.enumvalue_customname) = "NodeEventTypeJoin"];;
  51. // Leave event is generated when this node leaves the cluster.
  52. LEAVE = 2 [(gogoproto.enumvalue_customname) = "NodeEventTypeLeave"];;
  53. }
  54. Type type = 1;
  55. // Lamport time using a network lamport clock indicating the
  56. // time this event was generated on the node where it was
  57. // generated.
  58. uint64 l_time = 2 [(gogoproto.customtype) = "github.com/hashicorp/serf/serf.LamportTime", (gogoproto.nullable) = false];
  59. // Source node name.
  60. string node_name = 3;
  61. }
  62. // NetworkEvent message payload definition.
  63. message NetworkEvent {
  64. enum Type {
  65. option (gogoproto.goproto_enum_prefix) = false;
  66. option (gogoproto.enum_customname) = "Type";
  67. INVALID = 0 [(gogoproto.enumvalue_customname) = "NetworkEventTypeInvalid"];
  68. // Join event is generated when this node joins a network.
  69. JOIN = 1 [(gogoproto.enumvalue_customname) = "NetworkEventTypeJoin"];;
  70. // Leave event is generated when this node leaves a network.
  71. LEAVE = 2 [(gogoproto.enumvalue_customname) = "NetworkEventTypeLeave"];;
  72. }
  73. Type type = 1;
  74. // Lamport time using a network lamport clock indicating the
  75. // time this event was generated on the node where it was
  76. // generated.
  77. uint64 l_time = 2 [(gogoproto.customtype) = "github.com/hashicorp/serf/serf.LamportTime", (gogoproto.nullable) = false];
  78. // Source node name.
  79. string node_name = 3;
  80. // ID of the network for which the event is generated.
  81. string network_id = 4 [(gogoproto.customname) = "NetworkID"];
  82. }
  83. // NetworkEntry for push pull of networks.
  84. message NetworkEntry {
  85. // ID of the network
  86. string network_id = 1 [(gogoproto.customname) = "NetworkID"];
  87. // Latest lamport time of the network attachment when this
  88. // network event was recorded.
  89. uint64 l_time = 2 [(gogoproto.customtype) = "github.com/hashicorp/serf/serf.LamportTime", (gogoproto.nullable) = false];
  90. // Source node name where this network attachment happened.
  91. string node_name = 3;
  92. // Indicates if a leave from this network is in progress.
  93. bool leaving = 4;
  94. }
  95. // NetworkPushpull message payload definition.
  96. message NetworkPushPull {
  97. // Lamport time when this push pull was initiated.
  98. uint64 l_time = 1 [(gogoproto.customtype) = "github.com/hashicorp/serf/serf.LamportTime", (gogoproto.nullable) = false];
  99. repeated NetworkEntry networks = 2;
  100. }
  101. // TableEvent message payload definition.
  102. message TableEvent {
  103. enum Type {
  104. option (gogoproto.goproto_enum_prefix) = false;
  105. option (gogoproto.enum_customname) = "Type";
  106. INVALID = 0 [(gogoproto.enumvalue_customname) = "TableEventTypeInvalid"];
  107. // Create signifies that this table entry was just
  108. // created.
  109. CREATE = 1 [(gogoproto.enumvalue_customname) = "TableEventTypeCreate"];
  110. // Update signifies that this table entry was just
  111. // updated.
  112. UPDATE = 2 [(gogoproto.enumvalue_customname) = "TableEventTypeUpdate"];
  113. // Delete signifies that this table entry was just
  114. // updated.
  115. DELETE = 3 [(gogoproto.enumvalue_customname) = "TableEventTypeDelete"];
  116. }
  117. Type type = 1;
  118. // Lamport time when this event was generated.
  119. uint64 l_time = 2 [(gogoproto.customtype) = "github.com/hashicorp/serf/serf.LamportTime", (gogoproto.nullable) = false];
  120. // Node name where this event originated.
  121. string node_name = 3;
  122. // ID of the network to which this table entry belongs.
  123. string network_id = 4 [(gogoproto.customname) = "NetworkID"];
  124. // Name of the table to which this table entry belongs.
  125. string table_name = 5;
  126. // Entry key.
  127. string key = 6;
  128. // Entry value.
  129. bytes value = 7;
  130. }
  131. // BulkSync message payload definition.
  132. message BulkSyncMessage {
  133. // Lamport time when this bulk sync was initiated.
  134. uint64 l_time = 1 [(gogoproto.customtype) = "github.com/hashicorp/serf/serf.LamportTime", (gogoproto.nullable) = false];
  135. // Indicates if this bulksync is a response to a bulk sync
  136. // request from a peer node.
  137. bool unsolicited = 2;
  138. // Name of the node which is producing this bulk sync message.
  139. string node_name = 3;
  140. // List of network names whose table entries are getting
  141. // bulksynced as part of the bulksync.
  142. repeated string networks = 4;
  143. // Bulksync payload
  144. bytes payload = 5;
  145. }
  146. // Compound message payload definition.
  147. message CompoundMessage {
  148. message SimpleMessage {
  149. // Bytestring payload of a message constructed using
  150. // other message type definitions.
  151. bytes Payload = 1;
  152. }
  153. // A list of simple messages.
  154. repeated SimpleMessage messages = 1;
  155. }