raft.proto 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. syntax = "proto3";
  2. package docker.swarmkit.v1;
  3. import "objects.proto";
  4. import "types.proto";
  5. import "github.com/coreos/etcd/raft/raftpb/raft.proto";
  6. import weak "gogoproto/gogo.proto";
  7. import weak "plugin/plugin.proto";
  8. // Raft defines the RPC communication between raft nodes.
  9. service Raft {
  10. // ProcessRaftMessage sends a raft message to be processed on a raft member, it is
  11. // called from the RaftMember willing to send a message to its destination ('To' field)
  12. rpc ProcessRaftMessage(ProcessRaftMessageRequest) returns (ProcessRaftMessageResponse) {
  13. option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
  14. };
  15. // ResolveAddress returns the address where the node with the given ID can be reached.
  16. rpc ResolveAddress(ResolveAddressRequest) returns (ResolveAddressResponse) {
  17. option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
  18. };
  19. }
  20. // RaftMembership defines RPCs for adding and removing members from the
  21. // cluster. These RPCs must always run on the leader, so they are in a separate
  22. // service to support the raft proxy.
  23. service RaftMembership {
  24. // Join adds a RaftMember to the raft cluster.
  25. rpc Join(JoinRequest) returns (JoinResponse) {
  26. option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
  27. };
  28. // Leave removes a RaftMember from the raft cluster.
  29. rpc Leave(LeaveRequest) returns (LeaveResponse) {
  30. option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
  31. };
  32. }
  33. message RaftMember {
  34. // RaftID specifies the internal ID used by the manager in a raft context, it can never be modified
  35. // and is used only for information purposes
  36. uint64 raft_id = 1;
  37. // NodeID is the node's ID.
  38. string node_id = 2;
  39. // Addr specifies the address of the member
  40. string addr = 3;
  41. // Status provides the current status of the manager from the perspective of another manager.
  42. RaftMemberStatus status = 4 [(gogoproto.nullable) = false];
  43. }
  44. message JoinRequest {
  45. // Addr specifies the address of the member
  46. string addr = 1;
  47. }
  48. message JoinResponse {
  49. // RaftID is the ID assigned to the new member.
  50. uint64 raft_id = 1;
  51. // Members is the membership set of the cluster.
  52. repeated RaftMember members = 2;
  53. // RemovedMembers is a list of members that have been removed from
  54. // the cluster, so the new node can avoid communicating with them.
  55. repeated uint64 removed_members = 3 [packed=false];
  56. }
  57. message LeaveRequest {
  58. RaftMember node = 1;
  59. }
  60. message LeaveResponse {}
  61. message ProcessRaftMessageRequest {
  62. option (docker.protobuf.plugin.deepcopy) = false;
  63. raftpb.Message message = 1;
  64. }
  65. message ProcessRaftMessageResponse {}
  66. message ResolveAddressRequest {
  67. // raft_id is the ID to resolve to an address.
  68. uint64 raft_id = 1;
  69. }
  70. message ResolveAddressResponse {
  71. // Addr specifies the address of the member
  72. string addr = 1;
  73. }
  74. // Contains one of many protobuf encoded objects to replicate
  75. // over the raft backend with a request ID to track when the
  76. // action is effectively applied
  77. message InternalRaftRequest {
  78. uint64 id = 1;
  79. repeated StoreAction action = 2 [(gogoproto.nullable) = false];
  80. }
  81. // TODO(stevvooe): Storage actions may belong in another protobuf file. They
  82. // aren't necessarily first-class "types" in the cluster schema.
  83. // StoreActionKind defines the operation to take on the store for the target of
  84. // a storage action.
  85. enum StoreActionKind {
  86. option (gogoproto.goproto_enum_prefix) = false;
  87. option (gogoproto.enum_customname) = "StoreActionKind";
  88. UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "StoreActionKindUnknown"]; // default value, invalid
  89. STORE_ACTION_CREATE = 1 [(gogoproto.enumvalue_customname) = "StoreActionKindCreate"];
  90. STORE_ACTION_UPDATE = 2 [(gogoproto.enumvalue_customname) = "StoreActionKindUpdate"];
  91. STORE_ACTION_REMOVE = 3 [(gogoproto.enumvalue_customname) = "StoreActionKindRemove"];
  92. }
  93. // StoreAction defines a target and operation to apply on the storage system.
  94. message StoreAction {
  95. StoreActionKind action = 1;
  96. oneof target {
  97. Node node = 2;
  98. Service service = 3;
  99. Task task = 4;
  100. Network network = 5;
  101. Cluster cluster = 6;
  102. Secret secret = 7;
  103. Resource resource = 8;
  104. Extension extension = 9;
  105. Config config = 10;
  106. }
  107. }