Skip to content

Commit 0ffd1e8

Browse files
committed
Bump up the API to support getting the API version.
Signed-off-by: Gao Hongtao <[email protected]>
1 parent 6da79d9 commit 0ffd1e8

File tree

5 files changed

+95
-3
lines changed

5 files changed

+95
-3
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ Changes by Version
33
Release Notes.
44

55
0.8.0
6+
------------------
67

78
### Features
89

910
* Bump up the API to support the index mode of Measure.
1011
* Bump up the API to support the new property.
1112
* Bump up the API to adopt the status field which is changed to the string type due to the compatibility issue.
13+
* Bump up the API to support getting the API version.
1214

1315
0.7.0
1416
------------------

src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.apache.skywalking.banyandb.common.v1.BanyandbCommon;
3535
import org.apache.skywalking.banyandb.common.v1.BanyandbCommon.Group;
3636
import org.apache.skywalking.banyandb.common.v1.BanyandbCommon.Metadata;
37+
import org.apache.skywalking.banyandb.common.v1.ServiceGrpc;
3738
import org.apache.skywalking.banyandb.database.v1.BanyandbDatabase.TopNAggregation;
3839
import org.apache.skywalking.banyandb.database.v1.BanyandbDatabase.Measure;
3940
import org.apache.skywalking.banyandb.database.v1.BanyandbDatabase.Stream;
@@ -1069,6 +1070,20 @@ public MetadataCache.EntityMetadata updateMeasureMetadataCacheFromSever(String g
10691070
return this.metadataCache.updateMeasureFromSever(group, name);
10701071
}
10711072

1073+
/**
1074+
* Get the API version of the server
1075+
*
1076+
* @return the API version of the server
1077+
* @throws BanyanDBException if the server is not reachable
1078+
*/
1079+
public BanyandbCommon.APIVersion getAPIVersion() throws BanyanDBException {
1080+
ServiceGrpc.ServiceBlockingStub stub = ServiceGrpc.newBlockingStub(this.channel);
1081+
return HandleExceptionsWith.callAndTranslateApiException(() -> {
1082+
BanyandbCommon.GetAPIVersionResponse resp = stub.getAPIVersion(BanyandbCommon.GetAPIVersionRequest.getDefaultInstance());
1083+
return resp.getVersion();
1084+
});
1085+
}
1086+
10721087
@Override
10731088
public void close() throws IOException {
10741089
connectionEstablishLock.lock();

src/main/proto/banyandb/v1/banyandb-common.proto

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,29 @@ message Tag {
115115
// value is the value of the tag.
116116
string value = 2;
117117
}
118+
119+
120+
// APIVersion is the version of the API
121+
message APIVersion {
122+
// version is the version of the API
123+
string version = 1;
124+
// revision is the commit hash of the API
125+
string revision = 2;
126+
}
127+
128+
// GetAPIVersionRequest is the request for GetAPIVersion
129+
message GetAPIVersionRequest {
130+
// empty
131+
}
132+
133+
// GetAPIVersionResponse is the response for GetAPIVersion
134+
message GetAPIVersionResponse {
135+
// version is the version of the API
136+
APIVersion version = 1;
137+
}
138+
139+
// Service is the service for the API
140+
service Service {
141+
// GetAPIVersion returns the version of the API
142+
rpc GetAPIVersion(GetAPIVersionRequest) returns (GetAPIVersionResponse);
143+
}

src/test/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClientTestCI.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929

3030
@Slf4j
3131
public class BanyanDBClientTestCI {
32-
private static final String REGISTRY = "docker.io";
33-
private static final String IMAGE_NAME = "hanahmily/skywalking-banyandb";
34-
private static final String TAG = "v0.7.0-42-ga96ffb3-max-disk";
32+
private static final String REGISTRY = "ghcr.io";
33+
private static final String IMAGE_NAME = "apache/skywalking-banyandb";
34+
private static final String TAG = "362d68ed79c532e6d61dd6674cce38090caa0da7";
3535

3636
private static final String IMAGE = REGISTRY + "/" + IMAGE_NAME + ":" + TAG;
3737

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.banyandb.v1.client;
20+
21+
import com.google.common.base.Strings;
22+
import org.apache.skywalking.banyandb.common.v1.BanyandbCommon;
23+
import org.apache.skywalking.banyandb.v1.client.grpc.exception.BanyanDBException;
24+
import org.junit.After;
25+
import org.junit.Assert;
26+
import org.junit.Before;
27+
import org.junit.Test;
28+
29+
import java.io.IOException;
30+
31+
public class ITBanyanDBCommonTests extends BanyanDBClientTestCI {
32+
@Before
33+
public void setUp() throws IOException, BanyanDBException, InterruptedException {
34+
super.setUpConnection();
35+
}
36+
37+
@After
38+
public void tearDown() throws IOException {
39+
this.closeClient();
40+
}
41+
42+
@Test
43+
public void test_GetAPIVersion() throws BanyanDBException {
44+
BanyandbCommon.APIVersion version = this.client.getAPIVersion();
45+
Assert.assertEquals("0.8", version.getVersion());
46+
Assert.assertFalse(Strings.isNullOrEmpty(version.getRevision()));
47+
}
48+
49+
}

0 commit comments

Comments
 (0)