Skip to content

Commit a3d46f5

Browse files
committed
feat: add grpc plugin and Implemented code generation for gRPC services.
Signed-off-by: castlighting <[email protected]>
1 parent e79c915 commit a3d46f5

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

ci/spotbugs/exclude.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@
4242
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
4343
</Match>
4444

45+
<!-- Exclude gRPC auto-generated classes -->
46+
<Match>
47+
<Package name="io.opengemini.client.proto"/>
48+
</Match>
4549
</FindBugsFilter>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
syntax = "proto3";
2+
package proto;
3+
option java_multiple_files = true;
4+
option java_package = "io.opengemini.client.proto";
5+
option java_outer_classname = "WriteProto";
6+
7+
// WriteService represents a openGemini RPC write service.
8+
service WriteService {
9+
// Write writes the given records to the specified database and retention policy.
10+
rpc Write (WriteRequest) returns (WriteResponse) {}
11+
// Ping is used to check if the server is alive
12+
rpc Ping(PingRequest) returns (PingResponse) {}
13+
}
14+
15+
message WriteRequest {
16+
uint32 version = 1;
17+
string database = 2;
18+
string retention_policy = 3;
19+
string username = 4;
20+
string password = 5;
21+
repeated Record records = 6;
22+
}
23+
24+
message WriteResponse {
25+
ResponseCode code = 1;
26+
}
27+
28+
message Record {
29+
string measurement = 1;
30+
int64 min_time = 2;
31+
int64 max_time = 3;
32+
CompressMethod compress_method = 4;
33+
bytes block = 5;
34+
}
35+
36+
enum CompressMethod {
37+
UNCOMPRESSED = 0;
38+
LZ4_FAST = 1;
39+
ZSTD_FAST = 2;
40+
SNAPPY = 3;
41+
}
42+
43+
enum ResponseCode {
44+
Success = 0;
45+
Partial = 1;
46+
Failed = 2;
47+
}
48+
49+
message PingRequest {
50+
string client_id = 1;
51+
}
52+
53+
enum ServerStatus {
54+
Up = 0;
55+
Down = 1;
56+
Unknown = 99;
57+
}
58+
59+
message PingResponse {
60+
ServerStatus status = 1;
61+
}

pom.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,44 @@
188188
</execution>
189189
</executions>
190190
</plugin>
191+
<plugin>
192+
<groupId>org.xolstice.maven.plugins</groupId>
193+
<artifactId>protobuf-maven-plugin</artifactId>
194+
<version>${maven-protobuf-maven-plugin}</version>
195+
<configuration>
196+
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
197+
</protocArtifact>
198+
</configuration>
199+
<executions>
200+
<!-- Execution for grpc-java -->
201+
<execution>
202+
<id>grpc-java</id>
203+
<goals>
204+
<goal>compile</goal>
205+
<goal>compile-custom</goal>
206+
</goals>
207+
<configuration>
208+
<pluginId>grpc-java</pluginId>
209+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
210+
</pluginArtifact>
211+
</configuration>
212+
</execution>
213+
<!-- Execution for vertx-grpc -->
214+
<execution>
215+
<id>vertx-grpc</id>
216+
<goals>
217+
<goal>compile</goal>
218+
<goal>compile-custom</goal>
219+
</goals>
220+
<configuration>
221+
<pluginId>grpc-vertx</pluginId>
222+
<pluginArtifact>
223+
io.vertx:vertx-grpc-protoc-plugin:${vertx.version}:exe:${os.detected.classifier}
224+
</pluginArtifact>
225+
</configuration>
226+
</execution>
227+
</executions>
228+
</plugin>
191229
<plugin>
192230
<groupId>org.apache.maven.plugins</groupId>
193231
<artifactId>maven-compiler-plugin</artifactId>

0 commit comments

Comments
 (0)