Skip to content

Commit

Permalink
feat: add grpc plugin and Implemented code generation for gRPC services
Browse files Browse the repository at this point in the history
Signed-off-by: castlighting <[email protected]>
  • Loading branch information
castlighting committed Jan 2, 2025
1 parent e79c915 commit 5e98bff
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ci/spotbugs/exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
</Match>

<!-- Exclude gRPC auto-generated classes -->
<Match>
<Package name="io.opengemini.client.proto"/>
</Match>
</FindBugsFilter>
61 changes: 61 additions & 0 deletions opengemini-client/src/main/proto/write.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
syntax = "proto3";
package proto;
option java_multiple_files = true;
option java_package = "io.opengemini.client.proto";
option java_outer_classname = "WriteProto";

// WriteService represents a openGemini RPC write service.
service WriteService {
// Write writes the given records to the specified database and retention policy.
rpc Write (WriteRequest) returns (WriteResponse) {}
// Ping is used to check if the server is alive
rpc Ping(PingRequest) returns (PingResponse) {}
}

message WriteRequest {
uint32 version = 1;
string database = 2;
string retention_policy = 3;
string username = 4;
string password = 5;
repeated Record records = 6;
}

message WriteResponse {
ResponseCode code = 1;
}

message Record {
string measurement = 1;
int64 min_time = 2;
int64 max_time = 3;
CompressMethod compress_method = 4;
bytes block = 5;
}

enum CompressMethod {
UNCOMPRESSED = 0;
LZ4_FAST = 1;
ZSTD_FAST = 2;
SNAPPY = 3;
}

enum ResponseCode {
Success = 0;
Partial = 1;
Failed = 2;
}

message PingRequest {
string client_id = 1;
}

enum ServerStatus {
Up = 0;
Down = 1;
Unknown = 99;
}

message PingResponse {
ServerStatus status = 1;
}
38 changes: 38 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,44 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>${maven-protobuf-maven-plugin}</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
</protocArtifact>
</configuration>
<executions>
<!-- Execution for grpc-java -->
<execution>
<id>grpc-java</id>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
<configuration>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
</pluginArtifact>
</configuration>
</execution>
<!-- Execution for vertx-grpc -->
<execution>
<id>vertx-grpc</id>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
<configuration>
<pluginId>grpc-vertx</pluginId>
<pluginArtifact>
io.vertx:vertx-grpc-protoc-plugin:${vertx.version}:exe:${os.detected.classifier}
</pluginArtifact>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down

0 comments on commit 5e98bff

Please sign in to comment.