From 5e98bff222356743cc63f7ff65936c679124feaa Mon Sep 17 00:00:00 2001 From: castlighting Date: Thu, 2 Jan 2025 11:15:51 +0800 Subject: [PATCH 1/2] feat: add grpc plugin and Implemented code generation for gRPC services Signed-off-by: castlighting --- ci/spotbugs/exclude.xml | 4 ++ opengemini-client/src/main/proto/write.proto | 61 ++++++++++++++++++++ pom.xml | 38 ++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 opengemini-client/src/main/proto/write.proto diff --git a/ci/spotbugs/exclude.xml b/ci/spotbugs/exclude.xml index e53dad01..563c8699 100644 --- a/ci/spotbugs/exclude.xml +++ b/ci/spotbugs/exclude.xml @@ -42,4 +42,8 @@ + + + + diff --git a/opengemini-client/src/main/proto/write.proto b/opengemini-client/src/main/proto/write.proto new file mode 100644 index 00000000..d4eebb91 --- /dev/null +++ b/opengemini-client/src/main/proto/write.proto @@ -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; +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index ad0e8c18..4f0e0d82 100644 --- a/pom.xml +++ b/pom.xml @@ -188,6 +188,44 @@ + + org.xolstice.maven.plugins + protobuf-maven-plugin + ${maven-protobuf-maven-plugin} + + com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} + + + + + + grpc-java + + compile + compile-custom + + + grpc-java + io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} + + + + + + vertx-grpc + + compile + compile-custom + + + grpc-vertx + + io.vertx:vertx-grpc-protoc-plugin:${vertx.version}:exe:${os.detected.classifier} + + + + + org.apache.maven.plugins maven-compiler-plugin From 9902f3370d5941fae1fc794085d84f7664b69bb2 Mon Sep 17 00:00:00 2001 From: castlighting Date: Thu, 2 Jan 2025 11:26:27 +0800 Subject: [PATCH 2/2] fix: proto file line lint Signed-off-by: castlighting --- opengemini-client/src/main/proto/write.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opengemini-client/src/main/proto/write.proto b/opengemini-client/src/main/proto/write.proto index d4eebb91..5e51f2c7 100644 --- a/opengemini-client/src/main/proto/write.proto +++ b/opengemini-client/src/main/proto/write.proto @@ -58,4 +58,4 @@ enum ServerStatus { message PingResponse { ServerStatus status = 1; -} \ No newline at end of file +}