github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/libnetwork/networkdb/networkdb.proto (about)

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