Skip to content

Commit d3de7eb

Browse files
Interface refactor (#236)
This contains the refactor of the Java SDK to remove gRPC, and use the new interface system. Temporarily disables sdk-api-kotlin building, as we still need to work out a codegen for it.
1 parent fb1759a commit d3de7eb

File tree

169 files changed

+3061
-7264
lines changed

Some content is hidden

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

169 files changed

+3061
-7264
lines changed

admin-client/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies {
1717
implementation("org.openapitools:jackson-databind-nullable:0.2.6")
1818

1919
// Required for the annotations
20-
compileOnly(coreLibs.javax.annotation.api)
20+
compileOnly("org.apache.tomcat:annotations-api:6.0.53")
2121
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
2222
}
2323

admin-client/src/main/openapi/meta.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

build.gradle.kts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import net.ltgt.gradle.errorprone.errorprone
2-
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
3-
import org.gradle.api.tasks.testing.logging.TestLogEvent
42

53
plugins {
64
java
@@ -12,7 +10,6 @@ plugins {
1210
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
1311

1412
alias(pluginLibs.plugins.spotless)
15-
alias(pluginLibs.plugins.protobuf)
1613
}
1714

1815
val protobufVersion = coreLibs.versions.protobuf.get()
@@ -88,7 +85,6 @@ allprojects {
8885
subprojects {
8986
apply(plugin = "java")
9087
apply(plugin = "net.ltgt.errorprone")
91-
apply(plugin = "com.google.protobuf")
9288

9389
dependencies { errorprone("com.google.errorprone:error_prone_core:2.13.1") }
9490

@@ -100,8 +96,6 @@ subprojects {
10096
withSourcesJar()
10197
}
10298

103-
protobuf { protoc { artifact = "com.google.protobuf:protoc:$protobufVersion" } }
104-
10599
tasks.withType<JavaCompile>().configureEach {
106100
options.errorprone.disableWarningsInGeneratedCode.set(true)
107101
options.errorprone.disable(
@@ -114,26 +108,7 @@ subprojects {
114108
options.errorprone.excludedPaths.set(".*/build/generated/.*")
115109
}
116110

117-
val testReport =
118-
tasks.register<TestReport>("testReport") {
119-
destinationDirectory.set(layout.buildDirectory.dir("reports/tests/test"))
120-
testResults.setFrom(subprojects.mapNotNull { it.tasks.findByPath("test") })
121-
}
122-
123-
// Test platform and reporting
124-
tasks.withType<Test> {
125-
useJUnitPlatform()
126-
finalizedBy(testReport)
127-
testLogging {
128-
events(
129-
TestLogEvent.PASSED,
130-
TestLogEvent.SKIPPED,
131-
TestLogEvent.FAILED,
132-
TestLogEvent.STANDARD_ERROR,
133-
TestLogEvent.STANDARD_OUT)
134-
exceptionFormat = TestExceptionFormat.FULL
135-
}
136-
}
111+
tasks.withType<Test> { useJUnitPlatform() }
137112
}
138113

139114
nexusPublishing {

examples/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ Run:
2020

2121
You'll find the shadowed jar in the `build` directory.
2222

23-
The class to configure in Lambda is `dev.restate.sdk.examples.LambdaHandler`.
23+
The class to configure in Lambda is `my.restate.sdk.examples.LambdaHandler`.
2424

25-
By default, the [`dev.restate.sdk.examples.Counter`](src/main/java/dev/restate/sdk/examples/Counter.java) component is deployed. Set the env variable `LAMBDA_FACTORY_SERVICE_CLASS` to one of the available example classes to change the deployed class.
25+
By default, the [`dev.restate.sdk.examples.Counter`](src/main/java/dev/restate/sdk/examples/Counter.java) bindableComponent is deployed. Set the env variable `LAMBDA_FACTORY_SERVICE_CLASS` to one of the available example classes to change the deployed class.
2626

2727
## Running the examples (HTTP)
2828

29-
You can run the Java counter component via:
29+
You can run the Java counter bindableComponent via:
3030

3131
```shell
3232
./gradlew :examples:run
@@ -38,9 +38,9 @@ You can modify the class to run setting `-PmainClass=<FQCN>`, for example, in or
3838
./gradlew :examples:run -PmainClass=dev.restate.sdk.examples.CounterKt
3939
```
4040

41-
## Invoking the counter component
41+
## Invoking the counter bindableComponent
4242

43-
If you want to invoke the counter component via [grpcurl](https://github.com/fullstorydev/grpcurl):
43+
If you want to invoke the counter bindableComponent via [grpcurl](https://github.com/fullstorydev/grpcurl):
4444

4545
```shell
4646
grpcurl -plaintext -d '{"counter_name": "my_counter"}' localhost:9090 counter.Counter/Get

examples/build.gradle.kts

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import com.google.protobuf.gradle.id
2-
import com.google.protobuf.gradle.protobuf
3-
41
plugins {
52
java
6-
kotlin("jvm")
3+
// kotlin("jvm")
74
application
85
id("com.github.johnrengelman.shadow").version("7.1.2")
96
}
@@ -14,59 +11,25 @@ dependencies {
1411
implementation(project(":sdk-api"))
1512
implementation(project(":sdk-lambda"))
1613
implementation(project(":sdk-http-vertx"))
17-
implementation(project(":sdk-api-kotlin"))
14+
// implementation(project(":sdk-api-kotlin"))
1815
implementation(project(":sdk-serde-jackson"))
1916
implementation(project(":sdk-workflow-api"))
2017

18+
implementation(platform(jacksonLibs.jackson.bom))
19+
implementation(jacksonLibs.jackson.jsr310)
20+
2121
implementation(coreLibs.protobuf.java)
2222
implementation(coreLibs.protobuf.kotlin)
23-
implementation(coreLibs.grpc.stub)
24-
implementation(coreLibs.grpc.protobuf)
25-
implementation(coreLibs.grpc.netty)
26-
implementation(coreLibs.grpc.kotlin.stub) { exclude("javax.annotation", "javax.annotation-api") }
27-
28-
// Replace javax.annotations-api with tomcat annotations
29-
compileOnly(coreLibs.javax.annotation.api)
3023

3124
implementation(platform(vertxLibs.vertx.bom))
3225
implementation(vertxLibs.vertx.core)
3326
implementation(vertxLibs.vertx.kotlin.coroutines)
34-
implementation(vertxLibs.vertx.grpc.context.storage)
3527

3628
implementation(kotlinLibs.kotlinx.coroutines)
3729

3830
implementation(coreLibs.log4j.core)
3931
}
4032

41-
val pluginJar =
42-
file(
43-
"${project.rootProject.rootDir}/protoc-gen-restate/build/libs/protoc-gen-restate-${project.version}-all.jar")
44-
45-
protobuf {
46-
plugins {
47-
id("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:${coreLibs.versions.grpc.get()}" }
48-
id("restate") {
49-
// NOTE: This is not needed in a regular project configuration, you should rather use:
50-
// artifact = "dev.restate.sdk:protoc-gen-restate-java-blocking:1.0-SNAPSHOT:all@jar"
51-
path = pluginJar.path
52-
}
53-
}
54-
55-
generateProtoTasks {
56-
ofSourceSet("main").forEach {
57-
it.dependsOn(":protoc-gen-restate:shadowJar")
58-
it.plugins {
59-
id("grpc")
60-
id("restate") {
61-
option("java")
62-
option("kotlin")
63-
}
64-
}
65-
it.builtins { id("kotlin") }
66-
}
67-
}
68-
}
69-
7033
application {
7134
val mainClassValue: String =
7235
project.findProperty("mainClass")?.toString() ?: "dev.restate.sdk.examples.Counter"

examples/src/main/java/dev/restate/sdk/examples/Counter.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

examples/src/main/java/dev/restate/sdk/examples/VanillaGrpcCounter.java

Lines changed: 0 additions & 75 deletions
This file was deleted.

examples/src/main/java/dev/restate/sdk/examples/LambdaHandler.java renamed to examples/src/main/java/my/restate/sdk/examples/LambdaHandler.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// You can find a copy of the license in file LICENSE in the root
77
// directory of this repository or package, or at
88
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
9-
package dev.restate.sdk.examples;
9+
package my.restate.sdk.examples;
1010

1111
import dev.restate.sdk.lambda.BaseRestateLambdaHandler;
1212
import dev.restate.sdk.lambda.RestateLambdaEndpointBuilder;
@@ -22,11 +22,9 @@ public void register(RestateLambdaEndpointBuilder builder) {
2222
System.getenv("LAMBDA_FACTORY_SERVICE_CLASS"), Counter.class.getCanonicalName())
2323
.split(Pattern.quote(","))) {
2424
if (Counter.class.getCanonicalName().equals(serviceClass)) {
25-
builder.withService(new Counter());
26-
} else if (VanillaGrpcCounter.class.getCanonicalName().equals(serviceClass)) {
27-
builder.withService(new VanillaGrpcCounter());
28-
} else if (CounterKt.class.getCanonicalName().equals(serviceClass)) {
29-
builder.withService(new CounterKt());
25+
builder.with(new Counter());
26+
// } else if (CounterKt.class.getCanonicalName().equals(serviceClass)) {
27+
// builder.withService(new CounterKt());
3028
} else {
3129
throw new IllegalArgumentException(
3230
"Bad \"LAMBDA_FACTORY_SERVICE_CLASS\" env: " + serviceClass);

0 commit comments

Comments
 (0)