forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement] Add code style of protobuf and thrift (StarRocks#18052)
Add code style of protobuf and thrift. Signed-off-by: imay <buaa.zhaoc@gmail.com>
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Rules | ||
|
||
## Never use required | ||
|
||
As the project involving, any fields may become optional. But if it is defined as required, it can not be removed. | ||
|
||
So `required` should not be used. | ||
|
||
## Never change the ordinal | ||
|
||
To be back compatible, the ordinal of the field SHOULD NOT be changed. | ||
|
||
# Naming | ||
|
||
## file name | ||
|
||
The names of messages are all lowercase, with underscores between words. | ||
Files should end in `.proto`. | ||
|
||
``` | ||
my_message.proto // Good | ||
mymessage.proto // Bad | ||
my_message.pb // Bad | ||
``` | ||
|
||
## Message Name | ||
|
||
Message names start with a capital letter and have a capital letter for each new word, with no underscores, and with `PB` as postfix: MyMessagePB | ||
|
||
```protobuf | ||
message MyMessagePB // Good | ||
message MyMessage // Bad | ||
message My_Message_PB // Bad | ||
message myMessagePB // Bad | ||
``` | ||
|
||
## field name | ||
|
||
The names of messages are all lowercase, with underscores between words. | ||
|
||
``` | ||
optional int64 my_field = 3; // Good | ||
optional int64 myField = 3; // Bad | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Rules | ||
|
||
## Never use required | ||
|
||
As the project involving, any fields may become optional. But if it is defined as required, it can not be removed. | ||
|
||
So `required` should not be used. | ||
|
||
## Never change the ordinal | ||
|
||
To be back compatible, the ordinal of the field SHOULD NOT be changed. | ||
|
||
# Naming | ||
|
||
## file name | ||
|
||
The names of messages are all lowercase, with underscores between words. | ||
Files should end in `.thrift`. | ||
|
||
``` | ||
my_struct.thrift // Good | ||
MyStruct.thrift // Bad | ||
my_struct.proto // Bad | ||
``` | ||
|
||
## struct name | ||
|
||
Struct names start with a capital letter `T` and have a capital letter for each new word, with no underscores: TMyStruct | ||
|
||
``` | ||
struct TMyStruct; // Good | ||
struct MyStruct; // Bad | ||
struct TMy_Struct; // Bad | ||
struct TmyStruct; // Bad | ||
``` | ||
|
||
## field name | ||
|
||
The names of struct members are all lowercase, with underscores between words. | ||
|
||
``` | ||
1: optional i64 my_field; // Good | ||
1: optional i64 myField; // Bad | ||
``` |