Skip to content

Commit 88025d8

Browse files
Merge branch 'master' into feat/keyspace-encryptionpb
2 parents 3c0d10a + 534bbfa commit 88025d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+12823
-9240
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
root = true
2+
3+
[*.proto]
4+
indent_style = space
5+
indent_size = 2
6+
tab_width = 2
7+

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ init:
1313
check: init
1414
$(CURDIR)/scripts/check.sh
1515

16+
proto-fmt: init
17+
$(CURDIR)/scripts/proto_format.sh --write
18+
19+
proto-fmt-check: init
20+
$(CURDIR)/scripts/proto_format.sh --check
21+
1622
go: check
1723
# Standalone GOPATH
1824
$(CURDIR)/scripts/generate_go.sh

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ Protocol buffer files for TiKV
1717
* Go
1818
* Protoc 3.8.0
1919

20+
# Proto formatting
21+
22+
To avoid IDE-induced diffs, we use `buf format` to keep all `.proto` files consistently formatted.
23+
24+
* Check formatting (also runs as part of `make check`): `make proto-fmt-check`
25+
* Format in-place: `make proto-fmt`
26+
27+
The formatter is pinned and will be downloaded automatically into `./bin` (gitignored) when needed.
28+
If `make check` fails on formatting, run `make proto-fmt` and then rerun `make check`.
29+
2030
# Docker image
2131

2232
The easiest way to compile the protobufs is to use docker.

include/eraftpb.proto

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ syntax = "proto3";
22
package eraftpb;
33

44
enum EntryType {
5-
EntryNormal = 0;
6-
EntryConfChange = 1;
7-
EntryConfChangeV2 = 2;
5+
EntryNormal = 0;
6+
EntryConfChange = 1;
7+
EntryConfChangeV2 = 2;
88
}
99

1010
// The entry is a type of change that needs to be applied. It contains two data fields.
@@ -18,134 +18,134 @@ enum EntryType {
1818
// context will provide anything needed to assist the configuration change. The context
1919
// if for the user to set and use in this case.
2020
message Entry {
21-
EntryType entry_type = 1;
22-
uint64 term = 2;
23-
uint64 index = 3;
24-
bytes data = 4;
25-
bytes context = 6;
26-
27-
// Deprecated! It is kept for backward compatibility.
28-
// TODO: remove it in the next major release.
29-
bool sync_log = 5;
21+
EntryType entry_type = 1;
22+
uint64 term = 2;
23+
uint64 index = 3;
24+
bytes data = 4;
25+
bytes context = 6;
26+
27+
// Deprecated! It is kept for backward compatibility.
28+
// TODO: remove it in the next major release.
29+
bool sync_log = 5;
3030
}
3131

3232
message SnapshotMetadata {
33-
// The current `ConfState`.
34-
ConfState conf_state = 1;
35-
// The applied index.
36-
uint64 index = 2;
37-
// The term of the applied index.
38-
uint64 term = 3;
33+
// The current `ConfState`.
34+
ConfState conf_state = 1;
35+
// The applied index.
36+
uint64 index = 2;
37+
// The term of the applied index.
38+
uint64 term = 3;
3939
}
4040

4141
message Snapshot {
42-
bytes data = 1;
43-
SnapshotMetadata metadata = 2;
42+
bytes data = 1;
43+
SnapshotMetadata metadata = 2;
4444
}
4545

4646
enum MessageType {
47-
MsgHup = 0;
48-
MsgBeat = 1;
49-
MsgPropose = 2;
50-
MsgAppend = 3;
51-
MsgAppendResponse = 4;
52-
MsgRequestVote = 5;
53-
MsgRequestVoteResponse = 6;
54-
MsgSnapshot = 7;
55-
MsgHeartbeat = 8;
56-
MsgHeartbeatResponse = 9;
57-
MsgUnreachable = 10;
58-
MsgSnapStatus = 11;
59-
MsgCheckQuorum = 12;
60-
MsgTransferLeader = 13;
61-
MsgTimeoutNow = 14;
62-
MsgReadIndex = 15;
63-
MsgReadIndexResp = 16;
64-
MsgRequestPreVote = 17;
65-
MsgRequestPreVoteResponse = 18;
47+
MsgHup = 0;
48+
MsgBeat = 1;
49+
MsgPropose = 2;
50+
MsgAppend = 3;
51+
MsgAppendResponse = 4;
52+
MsgRequestVote = 5;
53+
MsgRequestVoteResponse = 6;
54+
MsgSnapshot = 7;
55+
MsgHeartbeat = 8;
56+
MsgHeartbeatResponse = 9;
57+
MsgUnreachable = 10;
58+
MsgSnapStatus = 11;
59+
MsgCheckQuorum = 12;
60+
MsgTransferLeader = 13;
61+
MsgTimeoutNow = 14;
62+
MsgReadIndex = 15;
63+
MsgReadIndexResp = 16;
64+
MsgRequestPreVote = 17;
65+
MsgRequestPreVoteResponse = 18;
6666
}
6767

6868
message Message {
69-
MessageType msg_type = 1;
70-
uint64 to = 2;
71-
uint64 from = 3;
72-
uint64 term = 4;
73-
uint64 log_term = 5;
74-
uint64 index = 6;
75-
repeated Entry entries = 7;
76-
uint64 commit = 8;
77-
Snapshot snapshot = 9;
78-
uint64 request_snapshot = 13;
79-
bool reject = 10;
80-
uint64 reject_hint = 11;
81-
bytes context = 12;
82-
uint64 deprecated_priority = 14;
83-
// If this new field is not set, then use the above old field; otherwise
84-
// use the new field. When broadcasting request vote, both fields are
85-
// set if the priority is larger than 0. This change is not a fully
86-
// compatible change, but it makes minimal impact that only new priority
87-
// is not recognized by the old nodes during rolling update.
88-
int64 priority = 15;
69+
MessageType msg_type = 1;
70+
uint64 to = 2;
71+
uint64 from = 3;
72+
uint64 term = 4;
73+
uint64 log_term = 5;
74+
uint64 index = 6;
75+
repeated Entry entries = 7;
76+
uint64 commit = 8;
77+
Snapshot snapshot = 9;
78+
uint64 request_snapshot = 13;
79+
bool reject = 10;
80+
uint64 reject_hint = 11;
81+
bytes context = 12;
82+
uint64 deprecated_priority = 14;
83+
// If this new field is not set, then use the above old field; otherwise
84+
// use the new field. When broadcasting request vote, both fields are
85+
// set if the priority is larger than 0. This change is not a fully
86+
// compatible change, but it makes minimal impact that only new priority
87+
// is not recognized by the old nodes during rolling update.
88+
int64 priority = 15;
8989
}
9090

9191
message HardState {
92-
uint64 term = 1;
93-
uint64 vote = 2;
94-
uint64 commit = 3;
92+
uint64 term = 1;
93+
uint64 vote = 2;
94+
uint64 commit = 3;
9595
}
9696

9797
enum ConfChangeTransition {
98-
// Automatically use the simple protocol if possible, otherwise fall back
99-
// to ConfChangeType::Implicit. Most applications will want to use this.
100-
Auto = 0;
101-
// Use joint consensus unconditionally, and transition out of them
102-
// automatically (by proposing a zero configuration change).
103-
//
104-
// This option is suitable for applications that want to minimize the time
105-
// spent in the joint configuration and do not store the joint configuration
106-
// in the state machine (outside of InitialState).
107-
Implicit = 1;
108-
// Use joint consensus and remain in the joint configuration until the
109-
// application proposes a no-op configuration change. This is suitable for
110-
// applications that want to explicitly control the transitions, for example
111-
// to use a custom payload (via the Context field).
112-
Explicit = 2;
98+
// Automatically use the simple protocol if possible, otherwise fall back
99+
// to ConfChangeType::Implicit. Most applications will want to use this.
100+
Auto = 0;
101+
// Use joint consensus unconditionally, and transition out of them
102+
// automatically (by proposing a zero configuration change).
103+
//
104+
// This option is suitable for applications that want to minimize the time
105+
// spent in the joint configuration and do not store the joint configuration
106+
// in the state machine (outside of InitialState).
107+
Implicit = 1;
108+
// Use joint consensus and remain in the joint configuration until the
109+
// application proposes a no-op configuration change. This is suitable for
110+
// applications that want to explicitly control the transitions, for example
111+
// to use a custom payload (via the Context field).
112+
Explicit = 2;
113113
}
114114

115115
message ConfState {
116-
repeated uint64 voters = 1;
117-
repeated uint64 learners = 2;
118-
119-
// The voters in the outgoing config. If not empty the node is in joint consensus.
120-
repeated uint64 voters_outgoing = 3;
121-
// The nodes that will become learners when the outgoing config is removed.
122-
// These nodes are necessarily currently in nodes_joint (or they would have
123-
// been added to the incoming config right away).
124-
repeated uint64 learners_next = 4;
125-
// If set, the config is joint and Raft will automatically transition into
126-
// the final config (i.e. remove the outgoing config) when this is safe.
127-
bool auto_leave = 5;
116+
repeated uint64 voters = 1;
117+
repeated uint64 learners = 2;
118+
119+
// The voters in the outgoing config. If not empty the node is in joint consensus.
120+
repeated uint64 voters_outgoing = 3;
121+
// The nodes that will become learners when the outgoing config is removed.
122+
// These nodes are necessarily currently in nodes_joint (or they would have
123+
// been added to the incoming config right away).
124+
repeated uint64 learners_next = 4;
125+
// If set, the config is joint and Raft will automatically transition into
126+
// the final config (i.e. remove the outgoing config) when this is safe.
127+
bool auto_leave = 5;
128128
}
129129

130130
enum ConfChangeType {
131-
AddNode = 0;
132-
RemoveNode = 1;
133-
AddLearnerNode = 2;
131+
AddNode = 0;
132+
RemoveNode = 1;
133+
AddLearnerNode = 2;
134134
}
135135

136136
message ConfChange {
137-
ConfChangeType change_type = 2;
138-
uint64 node_id = 3;
139-
bytes context = 4;
137+
ConfChangeType change_type = 2;
138+
uint64 node_id = 3;
139+
bytes context = 4;
140140

141-
uint64 id = 1;
141+
uint64 id = 1;
142142
}
143143

144144
// ConfChangeSingle is an individual configuration change operation. Multiple
145145
// such operations can be carried out atomically via a ConfChangeV2.
146146
message ConfChangeSingle {
147-
ConfChangeType change_type = 1;
148-
uint64 node_id = 2;
147+
ConfChangeType change_type = 1;
148+
uint64 node_id = 2;
149149
}
150150

151151
// ConfChangeV2 messages initiate configuration changes. They support both the
@@ -181,7 +181,7 @@ message ConfChangeSingle {
181181
//
182182
// [1]: https://github.com/ongardie/dissertation/blob/master/online-trim.pdf
183183
message ConfChangeV2 {
184-
ConfChangeTransition transition = 1;
185-
repeated ConfChangeSingle changes = 2;
186-
bytes context = 3;
184+
ConfChangeTransition transition = 1;
185+
repeated ConfChangeSingle changes = 2;
186+
bytes context = 3;
187187
}

include/rustproto.proto

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
syntax = "proto2";
22

3-
import "google/protobuf/descriptor.proto";
4-
53
// see https://github.com/gogo/protobuf/blob/master/gogoproto/gogo.proto
64
// for the original idea
75

86
package rustproto;
97

8+
import "google/protobuf/descriptor.proto";
9+
1010
extend google.protobuf.FileOptions {
11-
// When true, oneof field is generated public
12-
optional bool expose_oneof_all = 17001;
13-
// When true all fields are public, and not accessors generated
14-
optional bool expose_fields_all = 17003;
15-
// When false, `get_`, `set_`, `mut_` etc. accessors are not generated
16-
optional bool generate_accessors_all = 17004;
17-
// Use `bytes::Bytes` for `bytes` fields
18-
optional bool carllerche_bytes_for_bytes_all = 17011;
19-
// Use `bytes::Bytes` for `string` fields
20-
optional bool carllerche_bytes_for_string_all = 17012;
21-
// When true, will only generate codes that works with lite runtime.
22-
optional bool lite_runtime_all = 17035;
11+
// When true, oneof field is generated public
12+
optional bool expose_oneof_all = 17001;
13+
// When true all fields are public, and not accessors generated
14+
optional bool expose_fields_all = 17003;
15+
// When false, `get_`, `set_`, `mut_` etc. accessors are not generated
16+
optional bool generate_accessors_all = 17004;
17+
// Use `bytes::Bytes` for `bytes` fields
18+
optional bool carllerche_bytes_for_bytes_all = 17011;
19+
// Use `bytes::Bytes` for `string` fields
20+
optional bool carllerche_bytes_for_string_all = 17012;
21+
// When true, will only generate codes that works with lite runtime.
22+
optional bool lite_runtime_all = 17035;
2323
}
2424

2525
extend google.protobuf.MessageOptions {
26-
// When true, oneof field is generated public
27-
optional bool expose_oneof = 17001;
28-
// When true all fields are public, and not accessors generated
29-
optional bool expose_fields = 17003;
30-
// When false, `get_`, `set_`, `mut_` etc. accessors are not generated
31-
optional bool generate_accessors = 17004;
32-
// Use `bytes::Bytes` for `bytes` fields
33-
optional bool carllerche_bytes_for_bytes = 17011;
34-
// Use `bytes::Bytes` for `string` fields
35-
optional bool carllerche_bytes_for_string = 17012;
26+
// When true, oneof field is generated public
27+
optional bool expose_oneof = 17001;
28+
// When true all fields are public, and not accessors generated
29+
optional bool expose_fields = 17003;
30+
// When false, `get_`, `set_`, `mut_` etc. accessors are not generated
31+
optional bool generate_accessors = 17004;
32+
// Use `bytes::Bytes` for `bytes` fields
33+
optional bool carllerche_bytes_for_bytes = 17011;
34+
// Use `bytes::Bytes` for `string` fields
35+
optional bool carllerche_bytes_for_string = 17012;
3636
}
3737

3838
extend google.protobuf.FieldOptions {
39-
// When true all fields are public, and not accessors generated
40-
optional bool expose_fields_field = 17003;
41-
// When false, `get_`, `set_`, `mut_` etc. accessors are not generated
42-
optional bool generate_accessors_field = 17004;
43-
// Use `bytes::Bytes` for `bytes` fields
44-
optional bool carllerche_bytes_for_bytes_field = 17011;
45-
// Use `bytes::Bytes` for `string` fields
46-
optional bool carllerche_bytes_for_string_field = 17012;
47-
}
39+
// When true all fields are public, and not accessors generated
40+
optional bool expose_fields_field = 17003;
41+
// When false, `get_`, `set_`, `mut_` etc. accessors are not generated
42+
optional bool generate_accessors_field = 17004;
43+
// Use `bytes::Bytes` for `bytes` fields
44+
optional bool carllerche_bytes_for_bytes_field = 17011;
45+
// Use `bytes::Bytes` for `string` fields
46+
optional bool carllerche_bytes_for_string_field = 17012;
47+
}

0 commit comments

Comments
 (0)