Skip to content

Commit e19e539

Browse files
MichaelDeSteven庄松涛
andauthored
ci: add proto file comments linter (#733)
Co-authored-by: 庄松涛 <[email protected]>
1 parent c9e000d commit e19e539

File tree

4 files changed

+129
-4
lines changed

4 files changed

+129
-4
lines changed

.github/workflows/proto-linter.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Layotto Env Pipeline 🌊
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check:
10+
name: "🍀 Proto Validation"
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v2
15+
- name: buf-setup
16+
uses: bufbuild/buf-setup-action@v1
17+
with:
18+
version: '1.6.0'
19+
- name: buf-lint
20+
uses: bufbuild/buf-lint-action@v1
21+
- name: check it
22+
run: buf lint

buf.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: v1
2+
lint:
3+
use:
4+
- MINIMAL
5+
- COMMENT_ENUM
6+
- COMMENT_ENUM_VALUE
7+
- COMMENT_FIELD
8+
- COMMENT_MESSAGE
9+
- COMMENT_ONEOF
10+
- COMMENT_RPC
11+
- COMMENT_SERVICE

make/proto.mk

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,24 @@ proto.gen.doc:
2424

2525
.PHONY: proto.gen.init
2626
proto.gen.init:
27-
go install google.golang.org/protobuf/cmd/[email protected]
28-
go install google.golang.org/grpc/cmd/[email protected]
27+
go install google.golang.org/protobuf/cmd/[email protected]
28+
go install google.golang.org/grpc/cmd/[email protected]
2929

3030
.PHONY: proto.gen.code
3131
proto.gen.code:
3232
$(DOCKER) build -t layotto/protoc $(ROOT_DIR)/docker/proto && \
3333
$(DOCKER) run --rm \
3434
-v $(ROOT_DIR)/spec/proto/runtime/v1:/api/proto \
3535
layotto/protoc
36+
37+
.PHONY: proto.comments
38+
proto.comments:
39+
ifeq (,$(shell which buf))
40+
@echo "===========> Installing buf linter"
41+
@curl -fsSL \
42+
"https://github.com/bufbuild/buf/releases/download/v1.6.0/buf-$$(uname -s)-$$(uname -m)" \
43+
-o "$(OUTPUT_DIR)/buf"
44+
@sudo install -m 0755 $(OUTPUT_DIR)/buf /usr/local/bin/buf
45+
endif
46+
@echo "===========> Running buf linter"
47+
buf lint $(ROOT_DIR)

spec/proto/runtime/v1/runtime.proto

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ option go_package = "mosn.io/layotto/spec/proto/runtime/v1;runtime";
99
option java_outer_classname = "RuntimeProto";
1010
option java_package = "spec.proto.runtime.v1";
1111

12+
// Runtime encapsulates variours Runtime APIs(such as Configuration API, Pub/Sub API, etc)
1213
service Runtime {
1314
//SayHello used for test
1415
rpc SayHello(SayHelloRequest) returns (SayHelloResponse) {}
@@ -32,6 +33,7 @@ service Runtime {
3233
// A non-blocking method trying to get a lock with ttl.
3334
rpc TryLock(TryLockRequest)returns (TryLockResponse) {}
3435

36+
// A method trying to unlock.
3537
rpc Unlock(UnlockRequest)returns (UnlockResponse) {}
3638

3739
// Sequencer API
@@ -88,40 +90,53 @@ service Runtime {
8890
rpc GetBulkSecret(GetBulkSecretRequest) returns (GetBulkSecretResponse) {}
8991
}
9092

93+
// Get fileMeta request message
9194
message GetFileMetaRequest{
95+
// File meta request
9296
FileRequest request = 1;
9397
}
9498

99+
// Get fileMeta response message
95100
message GetFileMetaResponse{
96101
// The size of file
97102
int64 size = 1;
98103
// The modified time of file
99104
string last_modified = 2;
105+
// File meta response
100106
FileMeta response = 3;
101107
}
102108

109+
// FileMeta value
103110
message FileMetaValue{
111+
// File meta value
104112
repeated string value = 1;
105113
}
106114

115+
// A map that store FileMetaValue
107116
message FileMeta{
117+
// A data structure to store metadata
108118
map<string,FileMetaValue> metadata = 1;
109119
}
110120

121+
// Get file request message
111122
message GetFileRequest {
112-
//
123+
// The name of store
113124
string store_name = 1;
114125
// The name of the file or object want to get.
115126
string name = 2;
116127
// The metadata for user extension.
117128
map<string, string> metadata = 3;
118129
}
119130

131+
// Get file response message
120132
message GetFileResponse {
133+
// The data of file
121134
bytes data = 1;
122135
}
123136

137+
// Put file request message
124138
message PutFileRequest {
139+
// The name of store
125140
string store_name = 1;
126141
// The name of the file or object want to put.
127142
string name = 2;
@@ -131,20 +146,27 @@ message PutFileRequest {
131146
map<string, string> metadata = 4;
132147
}
133148

149+
// File request message
134150
message FileRequest {
151+
// The name of store
135152
string store_name = 1;
136153
// The name of the directory
137154
string name = 2;
138155
// The metadata for user extension.
139156
map<string, string> metadata = 3;
140157
}
141158

159+
// List file request message
142160
message ListFileRequest {
161+
// File request
143162
FileRequest request = 1;
163+
// Page size
144164
int32 page_size = 2;
165+
// Marker
145166
string marker = 3;
146167
}
147168

169+
// File info message
148170
message FileInfo {
149171
// The name of file
150172
string file_name = 1;
@@ -155,16 +177,24 @@ message FileInfo {
155177
// The metadata for user extension.
156178
map<string,string> metadata = 4;
157179
}
180+
181+
// List file response message
158182
message ListFileResp {
183+
// File info
159184
repeated FileInfo files = 1;
185+
// Marker
160186
string marker = 2;
187+
// Is truncated
161188
bool is_truncated = 3;
162189
}
163190

191+
// Delete file request message
164192
message DelFileRequest {
193+
// File request
165194
FileRequest request = 1;
166195
}
167196

197+
// Get next id request message
168198
message GetNextIdRequest {
169199
// Required. Name of sequencer storage
170200
string store_name = 1;
@@ -188,6 +218,7 @@ message SequencerOptions {
188218
STRONG = 1;
189219
}
190220

221+
// Default STRONG auto-increment
191222
AutoIncrement increment = 1;
192223

193224
// We removed Uniqueness enum to make it simple.
@@ -204,12 +235,14 @@ message SequencerOptions {
204235
// Uniqueness uniqueness=2;
205236
}
206237

238+
// Get next id response message
207239
message GetNextIdResponse{
208240
// The next unique id
209241
// Fixed int64 overflow problems on JavaScript https://github.com/improbable-eng/ts-protoc-gen#gotchas
210242
int64 next_id = 1 [jstype = JS_STRING];
211243
}
212244

245+
// Lock request message is distributed lock API which is not blocking method tring to get a lock with ttl
213246
message TryLockRequest {
214247
// Required. The lock store name,e.g. `redis`.
215248
string store_name = 1;
@@ -236,74 +269,116 @@ message TryLockRequest {
236269
int32 expire = 4;
237270
}
238271

272+
// Lock response message returns is the lock obtained.
239273
message TryLockResponse {
274+
// Is lock success
240275
bool success = 1;
241276
}
242277

278+
// UnLock request message
243279
message UnlockRequest {
280+
// The name of store
244281
string store_name = 1;
245282
// resource_id is the lock key.
246283
string resource_id = 2;
247-
284+
// The owner of the lock
248285
string lock_owner = 3;
249286
}
250287

288+
// UnLock response message
251289
message UnlockResponse {
290+
// The enum of unlock status
252291
enum Status {
292+
// Unlock is success
253293
SUCCESS = 0;
294+
// The lock is not exist
254295
LOCK_UNEXIST = 1;
296+
// The lock is belong to others
255297
LOCK_BELONG_TO_OTHERS = 2;
298+
// Internal error
256299
INTERNAL_ERROR = 3;
257300
}
258301

302+
// The status of unlock
259303
Status status = 1;
260304
}
261305

306+
// Hello request message
262307
message SayHelloRequest {
308+
// The name of service
263309
string service_name = 1;
310+
// Reuqest name
264311
string name = 2;
265312
// Optional. This field is used to control the packet size during load tests.
266313
google.protobuf.Any data = 3;
267314
}
268315

316+
// Hello response message
269317
message SayHelloResponse {
318+
// Hello
270319
string hello = 1;
320+
// Hello message of data
271321
google.protobuf.Any data = 2;
272322
}
273323

324+
// Invoke service request message
274325
message InvokeServiceRequest {
326+
// The identify of InvokeServiceRequest
275327
string id = 1;
328+
// InvokeServiceRequest message
276329
CommonInvokeRequest message = 3;
277330
}
278331

332+
// Common invoke request message which includes invoke method and data
279333
message CommonInvokeRequest {
334+
// The method of requset
280335
string method = 1;
336+
// The request data
281337
google.protobuf.Any data = 2;
338+
// The content type of request data
282339
string content_type = 3;
340+
// The extra information of http
283341
HTTPExtension http_extension = 4;
284342
}
285343

344+
// Http extension message is about invoke http information
286345
message HTTPExtension {
346+
// The enum of http reuest method
287347
enum Verb {
348+
// NONE
288349
NONE = 0;
350+
// GET method
289351
GET = 1;
352+
// HEAD method
290353
HEAD = 2;
354+
// POST method
291355
POST = 3;
356+
// PUT method
292357
PUT = 4;
358+
// DELETE method
293359
DELETE = 5;
360+
// CONNECT method
294361
CONNECT = 6;
362+
// CONNECT method
295363
OPTIONS = 7;
364+
// CONNECT method
296365
TRACE = 8;
366+
// PATCH method
297367
PATCH = 9;
298368
}
299369

370+
// The method of http reuest
300371
Verb verb = 1;
301372

373+
// The query information of http
302374
string querystring = 2;
303375
}
304376

377+
// Invoke service response message is result of invoke service queset
305378
message InvokeResponse {
379+
// The response data
306380
google.protobuf.Any data = 1;
381+
// The content type of response data
307382
string content_type = 2;
308383
}
309384

@@ -575,6 +650,7 @@ message StateOptions {
575650
// When an ETag is associated with an save or delete request, the store shall allow the update only if the attached ETag matches with the latest ETag in the database.
576651
// But when ETag is missing in the write requests, the state store shall handle the requests in the specified strategy(e.g. a last-write-wins fashion).
577652
enum StateConcurrency {
653+
// Concurrency state is unspecified
578654
CONCURRENCY_UNSPECIFIED = 0;
579655
// First write wins
580656
CONCURRENCY_FIRST_WRITE = 1;
@@ -584,6 +660,7 @@ message StateOptions {
584660

585661
// Enum describing the supported consistency for state.
586662
enum StateConsistency {
663+
// Consistency state is unspecified
587664
CONSISTENCY_UNSPECIFIED = 0;
588665
// The API server assumes data stores are eventually consistent by default.A state store should:
589666
// - For read requests, the state store can return data from any of the replicas
@@ -596,7 +673,9 @@ message StateOptions {
596673
CONSISTENCY_STRONG = 2;
597674
}
598675

676+
// The state operation of concurrency
599677
StateConcurrency concurrency = 1;
678+
// The state operation of consistency
600679
StateConsistency consistency = 2;
601680
}
602681

@@ -714,5 +793,6 @@ message GetBulkSecretResponse {
714793

715794
// SecretResponse is a map of decrypted string/string values
716795
message SecretResponse {
796+
// The data struct of secrets
717797
map<string, string> secrets = 1;
718798
}

0 commit comments

Comments
 (0)