Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New interface refactor #236

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
implementation("org.openapitools:jackson-databind-nullable:0.2.6")

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

Expand Down
2 changes: 1 addition & 1 deletion admin-client/src/main/openapi/meta.json

Large diffs are not rendered by default.

27 changes: 1 addition & 26 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import net.ltgt.gradle.errorprone.errorprone
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

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

alias(pluginLibs.plugins.spotless)
alias(pluginLibs.plugins.protobuf)
}

val protobufVersion = coreLibs.versions.protobuf.get()
Expand Down Expand Up @@ -88,7 +85,6 @@ allprojects {
subprojects {
apply(plugin = "java")
apply(plugin = "net.ltgt.errorprone")
apply(plugin = "com.google.protobuf")

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

Expand All @@ -100,8 +96,6 @@ subprojects {
withSourcesJar()
}

protobuf { protoc { artifact = "com.google.protobuf:protoc:$protobufVersion" } }

tasks.withType<JavaCompile>().configureEach {
options.errorprone.disableWarningsInGeneratedCode.set(true)
options.errorprone.disable(
Expand All @@ -114,26 +108,7 @@ subprojects {
options.errorprone.excludedPaths.set(".*/build/generated/.*")
}

val testReport =
tasks.register<TestReport>("testReport") {
destinationDirectory.set(layout.buildDirectory.dir("reports/tests/test"))
testResults.setFrom(subprojects.mapNotNull { it.tasks.findByPath("test") })
}

// Test platform and reporting
tasks.withType<Test> {
useJUnitPlatform()
finalizedBy(testReport)
testLogging {
events(
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.FAILED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT)
exceptionFormat = TestExceptionFormat.FULL
}
}
tasks.withType<Test> { useJUnitPlatform() }
}

nexusPublishing {
Expand Down
10 changes: 5 additions & 5 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ Run:

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

The class to configure in Lambda is `dev.restate.sdk.examples.LambdaHandler`.
The class to configure in Lambda is `my.restate.sdk.examples.LambdaHandler`.

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.
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.

## Running the examples (HTTP)

You can run the Java counter component via:
You can run the Java counter bindableComponent via:

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

## Invoking the counter component
## Invoking the counter bindableComponent

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

```shell
grpcurl -plaintext -d '{"counter_name": "my_counter"}' localhost:9090 counter.Counter/Get
Expand Down
47 changes: 5 additions & 42 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import com.google.protobuf.gradle.id
import com.google.protobuf.gradle.protobuf

plugins {
java
kotlin("jvm")
// kotlin("jvm")
application
id("com.github.johnrengelman.shadow").version("7.1.2")
}
Expand All @@ -14,59 +11,25 @@ dependencies {
implementation(project(":sdk-api"))
implementation(project(":sdk-lambda"))
implementation(project(":sdk-http-vertx"))
implementation(project(":sdk-api-kotlin"))
// implementation(project(":sdk-api-kotlin"))
implementation(project(":sdk-serde-jackson"))
implementation(project(":sdk-workflow-api"))

implementation(platform(jacksonLibs.jackson.bom))
implementation(jacksonLibs.jackson.jsr310)

implementation(coreLibs.protobuf.java)
implementation(coreLibs.protobuf.kotlin)
implementation(coreLibs.grpc.stub)
implementation(coreLibs.grpc.protobuf)
implementation(coreLibs.grpc.netty)
implementation(coreLibs.grpc.kotlin.stub) { exclude("javax.annotation", "javax.annotation-api") }

// Replace javax.annotations-api with tomcat annotations
compileOnly(coreLibs.javax.annotation.api)

implementation(platform(vertxLibs.vertx.bom))
implementation(vertxLibs.vertx.core)
implementation(vertxLibs.vertx.kotlin.coroutines)
implementation(vertxLibs.vertx.grpc.context.storage)

implementation(kotlinLibs.kotlinx.coroutines)

implementation(coreLibs.log4j.core)
}

val pluginJar =
file(
"${project.rootProject.rootDir}/protoc-gen-restate/build/libs/protoc-gen-restate-${project.version}-all.jar")

protobuf {
plugins {
id("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:${coreLibs.versions.grpc.get()}" }
id("restate") {
// NOTE: This is not needed in a regular project configuration, you should rather use:
// artifact = "dev.restate.sdk:protoc-gen-restate-java-blocking:1.0-SNAPSHOT:all@jar"
path = pluginJar.path
}
}

generateProtoTasks {
ofSourceSet("main").forEach {
it.dependsOn(":protoc-gen-restate:shadowJar")
it.plugins {
id("grpc")
id("restate") {
option("java")
option("kotlin")
}
}
it.builtins { id("kotlin") }
}
}
}

application {
val mainClassValue: String =
project.findProperty("mainClass")?.toString() ?: "dev.restate.sdk.examples.Counter"
Expand Down
58 changes: 0 additions & 58 deletions examples/src/main/java/dev/restate/sdk/examples/Counter.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdk.examples;
package my.restate.sdk.examples;

import dev.restate.sdk.lambda.BaseRestateLambdaHandler;
import dev.restate.sdk.lambda.RestateLambdaEndpointBuilder;
Expand All @@ -22,11 +22,9 @@ public void register(RestateLambdaEndpointBuilder builder) {
System.getenv("LAMBDA_FACTORY_SERVICE_CLASS"), Counter.class.getCanonicalName())
.split(Pattern.quote(","))) {
if (Counter.class.getCanonicalName().equals(serviceClass)) {
builder.withService(new Counter());
} else if (VanillaGrpcCounter.class.getCanonicalName().equals(serviceClass)) {
builder.withService(new VanillaGrpcCounter());
} else if (CounterKt.class.getCanonicalName().equals(serviceClass)) {
builder.withService(new CounterKt());
builder.with(new Counter());
// } else if (CounterKt.class.getCanonicalName().equals(serviceClass)) {
// builder.withService(new CounterKt());
} else {
throw new IllegalArgumentException(
"Bad \"LAMBDA_FACTORY_SERVICE_CLASS\" env: " + serviceClass);
Expand Down
Loading
Loading