Skip to content

Commit fa42030

Browse files
authored
Merge branch 'openGemini:main' into main
2 parents e79c915 + 345c1c6 commit fa42030

File tree

14 files changed

+155
-37
lines changed

14 files changed

+155
-37
lines changed

.github/workflows/java_unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ jobs:
3232
java-version: '17'
3333
distribution: 'temurin'
3434
- name: setup OpenGemini
35-
uses: shoothzj/setup-opengemini-action@main
35+
uses: hezhangjian/setup-opengemini-action@main
3636
- name: unit tests
3737
run: mvn -B clean test

.github/workflows/license_lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v4
2626
- name: licenselint
27-
uses: shoothzj/licenselint@main
27+
uses: hezhangjian/licenselint@main
2828
with:
2929
author: openGemini Authors

.github/workflows/line_lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v4
2626
- name: linelint
27-
uses: shoothzj/linelint@main
27+
uses: hezhangjian/linelint@main

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ docker run -p 8086:8086 --name opengemini --rm opengeminidb/opengemini-server
4646

4747
### HTTP Engine Selection
4848

49-
By default, the client uses the built-in HTTP engine provided by the JDK. It automatically selects the appropriate implementation based on the Java version, supporting both Java 8 and Java 11+. If needed, you can configure a different HTTP engine by specifying the `.engine` option in the `HttpClientConfig`. Please note, if a different engine is chosen, you will need to manually include the corresponding dependencies.
49+
OpenGeminiClient supports multiple [HTTP engines](https://github.com/openfacade/http-facade?tab=readme-ov-file#httpclient-support-engines) by leveraging [http-facade](https://github.com/openfacade/http-facade). By default, the client uses the built-in HTTP engine provided by the JDK. It automatically selects the appropriate implementation based on the Java version, supporting both Java 8 and Java 11+. If needed, you can configure a different HTTP engine by specifying the `.engine` option in the `HttpClientConfig`. Please note, if a different engine is chosen, you will need to manually include the corresponding dependencies.
5050

5151
## Quick Start
5252

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ docker run -p 8086:8086 --name opengemini --rm opengeminidb/opengemini-server
4646

4747
### HTTP 引擎选择
4848

49-
默认情况下,客户端使用 JDK 自带的 HTTP 引擎,并根据 Java 版本自动选择合适的实现,支持 Java 8 和 Java 11+。如果有需要,你可以在 `HttpClientConfig` 中通过 `.engine` 选项配置不同的 HTTP 引擎。请注意,若选择不同的引擎,则需要手动添加相应的依赖。
49+
OpenGeminiClient利用 [http-façade](https://github.com/openfacade/http-façade) 支持了多个 [HTTP 引擎](https://github.com/openfacade/http-façade?tab=readme-ov-file#httpclient-support-engines)默认情况下,客户端使用 JDK 自带的 HTTP 引擎,并根据 Java 版本自动选择合适的实现,支持 Java 8 和 Java 11+。如果有需要,你可以在 `HttpClientConfig` 中通过 `.engine` 选项配置不同的 HTTP 引擎。请注意,若选择不同的引擎,则需要手动添加相应的依赖。
5050

5151
## 快速上手
5252

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>

opengemini-client-common/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@
3232
<artifactId>opengemini-client-api</artifactId>
3333
<version>${project.version}</version>
3434
</dependency>
35+
<dependency>
36+
<groupId>org.xerial.snappy</groupId>
37+
<artifactId>snappy-java</artifactId>
38+
<version>${snappy.version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>com.github.luben</groupId>
42+
<artifactId>zstd-jni</artifactId>
43+
<version>${zstd.version}</version>
44+
</dependency>
3545
<dependency>
3646
<groupId>org.apache.commons</groupId>
3747
<artifactId>commons-lang3</artifactId>

opengemini-client/src/main/java/io/opengemini/client/impl/OpenGeminiClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected CompletableFuture<Pong> executePing() {
101101
.orElse(null)).thenApply(Pong::new);
102102
}
103103

104-
private <T> @NotNull CompletableFuture<T> convertResponse(HttpResponse response, Class<T> type) {
104+
private @NotNull <T> CompletableFuture<T> convertResponse(HttpResponse response, Class<T> type) {
105105
if (response.statusCode() >= 200 && response.statusCode() < 300) {
106106
try {
107107
T resp = JacksonService.toObject(response.body(), type);
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+
}

opengemini-client/src/test/java/io/opengemini/client/impl/OpenGeminiClientTest.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class OpenGeminiClientTest extends TestBase {
5757

5858
protected List<OpenGeminiClient> clientList() throws OpenGeminiException {
5959
List<HttpClientEngine> engines = new ArrayList<>();
60-
engines.add(HttpClientEngine.AsyncHttpClient);
61-
engines.add(HttpClientEngine.JAVA);
62-
engines.add(HttpClientEngine.JAVA8);
60+
engines.add(HttpClientEngine.Async);
61+
engines.add(HttpClientEngine.Java);
62+
engines.add(HttpClientEngine.Java8);
6363
engines.add(HttpClientEngine.OkHttp);
6464
List<OpenGeminiClient> clients = new ArrayList<>();
6565
for (HttpClientEngine engine : engines) {
@@ -68,10 +68,12 @@ protected List<OpenGeminiClient> clientList() throws OpenGeminiException {
6868
.connectTimeout(Duration.ofSeconds(3))
6969
.timeout(Duration.ofSeconds(3))
7070
.build();
71-
Configuration configuration = Configuration.builder()
72-
.addresses(Collections.singletonList(new Address("127.0.0.1", 8086)))
73-
.httpConfig(httpConfig)
74-
.build();
71+
Configuration configuration =
72+
Configuration.builder()
73+
.addresses(Collections.singletonList(new Address("127.0.0.1", 8086)))
74+
.httpConfig(httpConfig)
75+
.gzipEnabled(false)
76+
.build();
7577
clients.add(OpenGeminiClientFactory.create(configuration));
7678
}
7779
return clients;
@@ -89,6 +91,7 @@ void setUp() {
8991
.addresses(Collections.singletonList(new Address("127.0.0.1", 8086)))
9092
.httpConfig(httpConfig)
9193
.authConfig(new AuthConfig(AuthType.PASSWORD, "test", "testPwd123@".toCharArray(), null))
94+
.gzipEnabled(false)
9295
.build();
9396
this.openGeminiClient = new OpenGeminiClient(configuration);
9497
}
@@ -261,6 +264,7 @@ void query_should_throws_exception_when_address_is_wrong() throws IOException {
261264
Configuration configuration = Configuration.builder()
262265
.addresses(Collections.singletonList(new Address("127.0.0.1", 28086)))
263266
.httpConfig(new HttpClientConfig.Builder().build())
267+
.gzipEnabled(false)
264268
.build();
265269

266270
try (OpenGeminiClient wrongClient = new OpenGeminiClient(configuration)) {

0 commit comments

Comments
 (0)