Skip to content

Commit 5525aa6

Browse files
committed
feat: extend cluster/nodes to async client
1 parent fbacbaf commit 5525aa6

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

src/main/java/io/weaviate/client6/v1/api/WeaviateClientAsync.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import io.weaviate.client6.v1.api.alias.WeaviateAliasClientAsync;
88
import io.weaviate.client6.v1.api.backup.WeaviateBackupClientAsync;
9+
import io.weaviate.client6.v1.api.cluster.WeaviateClusterClientAsync;
910
import io.weaviate.client6.v1.api.collections.WeaviateCollectionsClient;
1011
import io.weaviate.client6.v1.api.collections.WeaviateCollectionsClientAsync;
1112
import io.weaviate.client6.v1.api.rbac.groups.WeaviateGroupsClientAsync;
@@ -52,6 +53,12 @@ public class WeaviateClientAsync implements AutoCloseable {
5253
*/
5354
public final WeaviateUsersClientAsync users;
5455

56+
/**
57+
* Client for {@code /nodes} and {@code /replication} endpoints
58+
* for managing replication and sharding.
59+
*/
60+
public final WeaviateClusterClientAsync cluster;
61+
5562
/**
5663
* This constructor is blocking if {@link Authentication} configured,
5764
* as the client will need to do the initial token exchange.
@@ -110,6 +117,7 @@ public WeaviateClientAsync(Config config) {
110117
this.roles = new WeaviateRolesClientAsync(restTransport);
111118
this.groups = new WeaviateGroupsClientAsync(restTransport);
112119
this.users = new WeaviateUsersClientAsync(restTransport);
120+
this.cluster = new WeaviateClusterClientAsync(restTransport);
113121
this.collections = new WeaviateCollectionsClientAsync(restTransport, grpcTransport);
114122
}
115123

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package io.weaviate.client6.v1.api.cluster;
2+
3+
import java.io.IOException;
4+
import java.util.List;
5+
import java.util.Optional;
6+
import java.util.concurrent.CompletableFuture;
7+
import java.util.function.Function;
8+
9+
import io.weaviate.client6.v1.internal.ObjectBuilder;
10+
import io.weaviate.client6.v1.internal.rest.RestTransport;
11+
12+
public class WeaviateClusterClientAsync {
13+
private final RestTransport restTransport;
14+
15+
public WeaviateClusterClientAsync(RestTransport restTransport) {
16+
this.restTransport = restTransport;
17+
}
18+
19+
/**
20+
* Query sharding state of a collection.
21+
*
22+
* @param collection Collection name.
23+
*/
24+
public CompletableFuture<Optional<ShardingState>> shardingState(String collection) throws IOException {
25+
return this.restTransport.performRequestAsync(ListShardsRequest.of(collection), ListShardsRequest._ENDPOINT);
26+
}
27+
28+
/**
29+
* Query sharding state of a collection.
30+
*
31+
* @param collection Collection name.
32+
* @param fn Lambda expression for optional parameters.
33+
*/
34+
public CompletableFuture<Optional<ShardingState>> shardingState(String collection,
35+
Function<ListShardsRequest.Builder, ObjectBuilder<ListShardsRequest>> fn)
36+
throws IOException {
37+
return this.restTransport.performRequestAsync(ListShardsRequest.of(collection, fn), ListShardsRequest._ENDPOINT);
38+
}
39+
40+
/**
41+
* Get the status of all nodes in the cluster.
42+
*
43+
* @param fn Lambda expression for optional parameters.
44+
*/
45+
public CompletableFuture<List<Node>> listNodes()
46+
throws IOException {
47+
return this.restTransport.performRequestAsync(ListNodesRequest.of(), ListNodesRequest._ENDPOINT);
48+
}
49+
50+
/**
51+
* Get the status of all nodes in the cluster.
52+
*
53+
* @param fn Lambda expression for optional parameters.
54+
*/
55+
public CompletableFuture<List<Node>> listNodes(Function<ListNodesRequest.Builder, ObjectBuilder<ListNodesRequest>> fn)
56+
throws IOException {
57+
return this.restTransport.performRequestAsync(ListNodesRequest.of(fn), ListNodesRequest._ENDPOINT);
58+
}
59+
}

0 commit comments

Comments
 (0)