File: raft.proto

package info (click to toggle)
docker.io 26.1.5%2Bdfsg1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,576 kB
  • sloc: sh: 5,748; makefile: 912; ansic: 664; asm: 228; python: 162
file content (151 lines) | stat: -rw-r--r-- 5,169 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
syntax = "proto3";

package docker.swarmkit.v1;

import "github.com/docker/swarmkit/api/objects.proto";
import "github.com/docker/swarmkit/api/types.proto";
import "go.etcd.io/etcd/raft/v3/raftpb/raft.proto";
import weak "gogoproto/gogo.proto";
import weak "github.com/docker/swarmkit/protobuf/plugin/plugin.proto";

// Raft defines the RPC communication between raft nodes.
service Raft {
	// ProcessRaftMessage sends a raft message to be processed on a raft member, it is
	// called from the RaftMember willing to send a message to its destination ('To' field)
	rpc ProcessRaftMessage(ProcessRaftMessageRequest) returns (ProcessRaftMessageResponse) {
		option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
	};

	// StreamRaftMessage accepts a stream of raft messages of type StreamRaftMessageRequest
	// to be processed on a raft member, returning a StreamRaftMessageResponse 
	// when processing of the streamed messages is complete. A single stream corresponds 
	// to a single raft message, which may be disassembled and streamed as individual messages.
	// It is called from the Raft leader, which uses it to stream messages to a raft member.
	rpc StreamRaftMessage(stream StreamRaftMessageRequest) returns (StreamRaftMessageResponse) {
		option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
	};

	// ResolveAddress returns the address where the node with the given ID can be reached.
	rpc ResolveAddress(ResolveAddressRequest) returns (ResolveAddressResponse) {
		option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
	};
}

// RaftMembership defines RPCs for adding and removing members from the
// cluster. These RPCs must always run on the leader, so they are in a separate
// service to support the raft proxy.
service RaftMembership {
	// Join adds a RaftMember to the raft cluster.
	rpc Join(JoinRequest) returns (JoinResponse) {
		option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
	};

	// Leave removes a RaftMember from the raft cluster.
	rpc Leave(LeaveRequest) returns (LeaveResponse) {
		option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
	};
}

message RaftMember {
	// RaftID specifies the internal ID used by the manager in a raft context, it can never be modified
	// and is used only for information purposes
	uint64 raft_id = 1;

	// NodeID is the node's ID.
	string node_id = 2;

	// Addr specifies the address of the member
	string addr = 3;

	// Status provides the current status of the manager from the perspective of another manager.
	RaftMemberStatus status = 4 [(gogoproto.nullable) = false];
}

message JoinRequest {
	// Addr specifies the address of the member
	string addr = 1;
}

message JoinResponse {
	// RaftID is the ID assigned to the new member.
	uint64 raft_id = 1;

	// Members is the membership set of the cluster.
	repeated RaftMember members = 2;

	// RemovedMembers is a list of members that have been removed from
	// the cluster, so the new node can avoid communicating with them.
	repeated uint64 removed_members = 3 [packed=false];
}

message LeaveRequest {
	RaftMember node = 1;
}

message LeaveResponse {}

message ProcessRaftMessageRequest {
	option (docker.protobuf.plugin.deepcopy) = false;
	raftpb.Message message = 1;
}

message ProcessRaftMessageResponse {}

// Raft message streaming request.
message StreamRaftMessageRequest {
	option (docker.protobuf.plugin.deepcopy) = false;
	raftpb.Message message = 1;
}

// Raft message streaming response.
message StreamRaftMessageResponse {}

message ResolveAddressRequest {
	// raft_id is the ID to resolve to an address.
	uint64 raft_id = 1;
}

message ResolveAddressResponse {
	// Addr specifies the address of the member
	string addr = 1;
}

// Contains one of many protobuf encoded objects to replicate
// over the raft backend with a request ID to track when the
// action is effectively applied
message InternalRaftRequest {
	uint64 id = 1;

	repeated StoreAction action = 2 [(gogoproto.nullable) = false];
}

// TODO(stevvooe): Storage actions may belong in another protobuf file. They
// aren't necessarily first-class "types" in the cluster schema.

// StoreActionKind defines the operation to take on the store for the target of
// a storage action.
enum StoreActionKind {
	option (gogoproto.goproto_enum_prefix) = false;
	option (gogoproto.enum_customname) = "StoreActionKind";
	UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "StoreActionKindUnknown"]; // default value, invalid
	STORE_ACTION_CREATE = 1 [(gogoproto.enumvalue_customname) = "StoreActionKindCreate"];
	STORE_ACTION_UPDATE = 2 [(gogoproto.enumvalue_customname) = "StoreActionKindUpdate"];
	STORE_ACTION_REMOVE = 3 [(gogoproto.enumvalue_customname) = "StoreActionKindRemove"];
}

// StoreAction defines a target and operation to apply on the storage system.
message StoreAction {
	StoreActionKind action = 1;
	oneof target {
		Node node = 2;
		Service service = 3;
		Task task = 4;
		Network network = 5;
		Cluster cluster = 6;
		Secret secret = 7;
		Resource resource = 8;
		Extension extension = 9;
		Config config = 10;
		Volume volume = 11;
	}
}