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