Skip to content

Commit 978dfd1

Browse files
jackye1995claude
andauthored
feat(java): add async client and interface with CompletableFuture support (#316)
## Summary Add two new Java modules for async operations using Java 11+ native HttpClient: - **lance-namespace-async-client**: Generated async HTTP client using `library=native,asyncNative=true` - Uses Java 11+ `java.net.http.HttpClient` - All API methods return `CompletableFuture<T>` - **lance-namespace-core-async**: Async version of LanceNamespace interface - `LanceNamespaceAsync` interface mirroring `LanceNamespace` - All methods return `CompletableFuture<T>` - Includes async error classes ### Key Changes - Add `async-client-pom.xml` (copied after codegen, following Rust's pattern) - Update Makefile with async client targets - Update `checkstyle-suppressions.xml` for async client - Update `java-publish.yml` to include async modules in Maven Central check ### Usage ```java // Sync (existing) LanceNamespace ns = LanceNamespace.connect("rest", props, allocator); ListTablesResponse response = ns.listTables(request); // Async (new) LanceNamespaceAsync ns = LanceNamespaceAsync.connect("rest", props, allocator); CompletableFuture<ListTablesResponse> future = ns.listTables(request); ``` ### Maven Dependencies ```xml <!-- Async interface (Java 11+) --> <dependency> <groupId>org.lance</groupId> <artifactId>lance-namespace-core-async</artifactId> <version>${version}</version> </dependency> <!-- Async client (Java 11+) --> <dependency> <groupId>org.lance</groupId> <artifactId>lance-namespace-async-client</artifactId> <version>${version}</version> </dependency> ``` ## Test plan - [x] `make check` passes (checkstyle + spotless) - [x] `make build` passes (all modules compile) - [x] CI workflows updated to include new modules 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 505b547 commit 978dfd1

File tree

305 files changed

+83932
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

305 files changed

+83932
-8
lines changed

.github/workflows/java-publish.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ jobs:
106106
# List of some artifacts to check
107107
ARTIFACTS=(
108108
"lance-namespace-apache-client"
109+
"lance-namespace-async-client"
109110
"lance-namespace-core"
111+
"lance-namespace-core-async"
110112
)
111113
112114
echo "Waiting for version $VERSION to be available in Maven Central..."
@@ -137,23 +139,41 @@ jobs:
137139
echo ""
138140
echo "Users can now add the following dependencies to their projects:"
139141
echo ""
140-
echo "Maven (interface):"
142+
echo "Maven (sync interface):"
141143
echo "<dependency>"
142144
echo " <groupId>org.lance</groupId>"
143145
echo " <artifactId>lance-namespace-core</artifactId>"
144146
echo " <version>${VERSION}</version>"
145147
echo "</dependency>"
146148
echo ""
147-
echo "Maven (generated client):"
149+
echo "Maven (async interface - Java 11+):"
150+
echo "<dependency>"
151+
echo " <groupId>org.lance</groupId>"
152+
echo " <artifactId>lance-namespace-core-async</artifactId>"
153+
echo " <version>${VERSION}</version>"
154+
echo "</dependency>"
155+
echo ""
156+
echo "Maven (sync client):"
148157
echo "<dependency>"
149158
echo " <groupId>org.lance</groupId>"
150159
echo " <artifactId>lance-namespace-apache-client</artifactId>"
151160
echo " <version>${VERSION}</version>"
152161
echo "</dependency>"
153162
echo ""
154-
echo "Gradle:"
163+
echo "Maven (async client - Java 11+):"
164+
echo "<dependency>"
165+
echo " <groupId>org.lance</groupId>"
166+
echo " <artifactId>lance-namespace-async-client</artifactId>"
167+
echo " <version>${VERSION}</version>"
168+
echo "</dependency>"
169+
echo ""
170+
echo "Gradle (sync):"
155171
echo "implementation 'org.lance:lance-namespace-core:${VERSION}'"
156172
echo "implementation 'org.lance:lance-namespace-apache-client:${VERSION}'"
173+
echo ""
174+
echo "Gradle (async - Java 11+):"
175+
echo "implementation 'org.lance:lance-namespace-core-async:${VERSION}'"
176+
echo "implementation 'org.lance:lance-namespace-async-client:${VERSION}'"
157177
exit 0
158178
fi
159179

java/.async-client-ignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
**build.gradle
2+
**.travis.yml
3+
**build.sbt
4+
**git_push.sh
5+
**gradle.properties
6+
**gradlew
7+
**gradlew.bat
8+
**settings.gradle
9+
**.gitignore
10+
**/gradle/**
11+
**/.github/**
12+
**/src/test/**

java/Makefile

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,36 @@
1212

1313
VERSION = 0.5.2
1414

15+
.PHONY: clean-async-client
16+
clean-async-client:
17+
rm -rf lance-namespace-async-client
18+
19+
.PHONY: gen-async-client
20+
gen-async-client: clean-async-client
21+
uv run openapi-generator-cli generate \
22+
-i ../docs/src/rest.yaml \
23+
-g java \
24+
-o lance-namespace-async-client \
25+
--ignore-file-override=.async-client-ignore \
26+
--type-mappings=file=byte[] \
27+
--additional-properties=groupId=org.lance,artifactId=lance-namespace-async-client,artifactVersion=$(VERSION),parentGroupId=org.lance,parentArtifactId=lance-namespace-root,parentVersion=$(VERSION),parentRelativePath=pom.xml,library=native,asyncNative=true,apiPackage=org.lance.namespace.client.async.api,modelPackage=org.lance.namespace.model,hideGenerationTimestamp=true,licenseName=Apache-2.0,licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.txt
28+
rm -rf lance-namespace-async-client/.openapi-generator-ignore
29+
rm -rf lance-namespace-async-client/.openapi-generator
30+
rm -rf lance-namespace-async-client/pom.xml
31+
cp async-client-pom.xml lance-namespace-async-client/pom.xml
32+
33+
.PHONY: lint-async-client
34+
lint-async-client: gen-async-client
35+
./mvnw spotless:apply -pl lance-namespace-async-client -am
36+
37+
.PHONY: build-async-client
38+
build-async-client: gen-async-client lint-async-client
39+
./mvnw install -pl lance-namespace-async-client -am
40+
41+
.PHONY: check-async-client
42+
check-async-client:
43+
./mvnw checkstyle:check spotless:check -pl lance-namespace-async-client -am
44+
1545
.PHONY: clean-apache-client
1646
clean-apache-client:
1747
rm -rf lance-namespace-apache-client
@@ -75,11 +105,24 @@ build-core: build-apache-client lint-core
75105
check-core:
76106
./mvnw checkstyle:check spotless:check -pl lance-namespace-core -am
77107

108+
# lance-namespace-core-async module (hand-written, no codegen)
109+
.PHONY: lint-core-async
110+
lint-core-async: gen-async-client
111+
./mvnw spotless:apply -pl lance-namespace-core-async -am
112+
113+
.PHONY: build-core-async
114+
build-core-async: build-async-client lint-core-async
115+
./mvnw install -pl lance-namespace-core-async -am
116+
117+
.PHONY: check-core-async
118+
check-core-async:
119+
./mvnw checkstyle:check spotless:check -pl lance-namespace-core-async -am
120+
78121
.PHONY: clean
79-
clean: clean-apache-client clean-springboot-server
122+
clean: clean-apache-client clean-async-client clean-springboot-server
80123

81124
.PHONY: gen
82-
gen: gen-apache-client gen-springboot-server lint-apache-client lint-springboot-server
125+
gen: gen-apache-client gen-async-client gen-springboot-server lint-apache-client lint-async-client lint-springboot-server
83126

84127
.PHONY: check-apache-client
85128
check-apache-client:
@@ -90,10 +133,10 @@ check-springboot-server:
90133
./mvnw checkstyle:check spotless:check -pl lance-namespace-springboot-server -am
91134

92135
.PHONY: check
93-
check: check-apache-client check-springboot-server check-core
136+
check: check-apache-client check-async-client check-springboot-server check-core check-core-async
94137

95138
.PHONY: lint
96-
lint: lint-apache-client lint-springboot-server lint-core
139+
lint: lint-apache-client lint-async-client lint-springboot-server lint-core lint-core-async
97140

98141
.PHONY: build
99-
build: build-apache-client build-springboot-server build-core
142+
build: build-apache-client build-async-client build-springboot-server build-core build-core-async

java/async-client-pom.xml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.lance</groupId>
9+
<artifactId>lance-namespace-root</artifactId>
10+
<version>0.5.2</version>
11+
</parent>
12+
13+
<artifactId>lance-namespace-async-client</artifactId>
14+
<packaging>jar</packaging>
15+
16+
<name>lance-namespace-async-client</name>
17+
<description>Lance Namespace async HTTP client using Java 11+ native HttpClient</description>
18+
19+
<dependencies>
20+
<!-- JSON processing: jackson -->
21+
<dependency>
22+
<groupId>com.fasterxml.jackson.core</groupId>
23+
<artifactId>jackson-core</artifactId>
24+
<version>${jackson-version}</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>com.fasterxml.jackson.core</groupId>
28+
<artifactId>jackson-annotations</artifactId>
29+
<version>${jackson-version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>com.fasterxml.jackson.core</groupId>
33+
<artifactId>jackson-databind</artifactId>
34+
<version>${jackson-version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>com.fasterxml.jackson.datatype</groupId>
38+
<artifactId>jackson-datatype-jsr310</artifactId>
39+
<version>${jackson-version}</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.openapitools</groupId>
43+
<artifactId>jackson-databind-nullable</artifactId>
44+
<version>${jackson-databind-nullable-version}</version>
45+
</dependency>
46+
47+
<!-- @Nullable annotation -->
48+
<dependency>
49+
<groupId>com.google.code.findbugs</groupId>
50+
<artifactId>jsr305</artifactId>
51+
<version>3.0.2</version>
52+
</dependency>
53+
<dependency>
54+
<groupId>jakarta.annotation</groupId>
55+
<artifactId>jakarta.annotation-api</artifactId>
56+
<version>${jakarta-annotation-version}</version>
57+
<scope>provided</scope>
58+
</dependency>
59+
60+
<!-- test dependencies -->
61+
<dependency>
62+
<groupId>org.junit.jupiter</groupId>
63+
<artifactId>junit-jupiter-api</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
</dependencies>
67+
68+
<build>
69+
<plugins>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-enforcer-plugin</artifactId>
73+
<version>3.1.0</version>
74+
<executions>
75+
<execution>
76+
<id>enforce-maven</id>
77+
<goals>
78+
<goal>enforce</goal>
79+
</goals>
80+
<configuration>
81+
<rules>
82+
<requireMavenVersion>
83+
<version>3</version>
84+
</requireMavenVersion>
85+
<requireJavaVersion>
86+
<version>11</version>
87+
</requireJavaVersion>
88+
</rules>
89+
</configuration>
90+
</execution>
91+
</executions>
92+
</plugin>
93+
<plugin>
94+
<groupId>org.apache.maven.plugins</groupId>
95+
<artifactId>maven-compiler-plugin</artifactId>
96+
<version>3.10.1</version>
97+
<configuration>
98+
<source>11</source>
99+
<target>11</target>
100+
<release>11</release>
101+
</configuration>
102+
</plugin>
103+
<plugin>
104+
<groupId>org.apache.maven.plugins</groupId>
105+
<artifactId>maven-surefire-plugin</artifactId>
106+
<version>3.2.5</version>
107+
</plugin>
108+
</plugins>
109+
</build>
110+
111+
<properties>
112+
<jackson-version>2.17.1</jackson-version>
113+
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
114+
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
115+
</properties>
116+
</project>

java/checkstyle-suppressions.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
<suppressions>
88
<suppress checks="MethodName" files="lance-namespace-apache-client/src/main/java/org/lance/namespace/client/apache/*"/>
99
<suppress checks="MethodName" files="lance-namespace-apache-client/src/main/java/org/lance/namespace/model/*"/>
10+
<suppress checks="MethodName" files="lance-namespace-async-client/src/main/java/org/lance/namespace/client/async/*"/>
11+
<suppress checks="MethodName" files="lance-namespace-async-client/src/main/java/org/lance/namespace/model/*"/>
1012
<suppress checks="MethodName" files="lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/*"/>
1113
<suppress checks="LineLength" files="lance-namespace-apache-client/src/main/java/org/lance/namespace/client/apache/*"/>
14+
<suppress checks="LineLength" files="lance-namespace-async-client/src/main/java/org/lance/namespace/client/async/*"/>
1215
<suppress checks="LineLength" files="lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/*"/>
1316
<suppress checks="RedundantModifier" files="lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/*"/>
1417
<suppress checks="NeedBraces" files="lance-namespace-apache-client/src/main/java/org/lance/namespace/client/apache/*"/>
18+
<suppress checks="NeedBraces" files="lance-namespace-async-client/src/main/java/org/lance/namespace/client/async/*"/>
1519
</suppressions>

0 commit comments

Comments
 (0)