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

Renamings #164

Merged
merged 2 commits into from
Nov 27, 2023
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
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ Scaffold a project using the build tool of your choice. For example, with Gradle
gradle init --type java-application
```

Add the dependency [sdk-java-blocking](sdk-java-blocking):
Add the dependency [sdk-api](sdk-api):

```
implementation("dev.restate.sdk:sdk-java-blocking:1.0-SNAPSHOT")
implementation("dev.restate:sdk-api:1.0-SNAPSHOT")
```

Now you need to configure the protobuf plugin to build your Protobuf contracts. For example, with Gradle (Kotlin script):
Expand Down Expand Up @@ -61,7 +61,7 @@ protobuf {
plugins {
// The Restate plugin depends on the gRPC generated code
id("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:1.58.0" }
id("restate") { artifact = "dev.restate.sdk:protoc-gen-restate-java-blocking:1.0-SNAPSHOT:all@jar" }
id("restate") { artifact = "dev.restate:protoc-gen-restate:1.0-SNAPSHOT:all@jar" }
}

generateProtoTasks {
Expand All @@ -85,10 +85,10 @@ Scaffold a project using the build tool of your choice. For example, with Gradle
gradle init --type kotlin-application
```

Add the dependency [`sdk-kotlin`](sdk-kotlin):
Add the dependency [`sdk-api-kotlin`](sdk-api-kotlin):

```
implementation("dev.restate.sdk:sdk-kotlin:1.0-SNAPSHOT")
implementation("dev.restate:sdk-api-kotlin:1.0-SNAPSHOT")
```

Now you need to configure the protobuf plugin to build your Protobuf contracts. For example, with Gradle (Kotlin script):
Expand Down Expand Up @@ -221,7 +221,7 @@ If you want to use POJOs for state, check [how to use Jackson](#state-serde-usin
To deploy the Restate service as HTTP server, add [`sdk-http-vertx`](sdk-http-vertx) to the dependencies. For example, in Gradle:

```
implementation("dev.restate.sdk:sdk-http-vertx:1.0-SNAPSHOT")
implementation("dev.restate:sdk-http-vertx:1.0-SNAPSHOT")
```

To deploy the service, add the following code to the `main`. For example in Java:
Expand Down Expand Up @@ -255,7 +255,7 @@ gradle run
To deploy the Restate service as Lambda, add [`sdk-lambda`](sdk-lambda) to the dependencies. For example, in Gradle:

```
implementation("dev.restate.sdk:sdk-lambda:1.0-SNAPSHOT")
implementation("dev.restate:sdk-lambda:1.0-SNAPSHOT")
```

Configure the build tool to generate Fat-JARs, which are required by AWS Lambda to correctly load the JAR. For example, using Gradle:
Expand Down Expand Up @@ -307,7 +307,7 @@ State ser/de is defined by the interface `Serde`. If you want to use [Jackson Da
For example, in Gradle:

```
implementation("dev.restate.sdk:sdk-serde-jackson:1.0-SNAPSHOT")
implementation("dev.restate:sdk-serde-jackson:1.0-SNAPSHOT")
```

And then use `JacksonSerdes`:
Expand Down
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ plugins {
val protobufVersion = coreLibs.versions.protobuf.get()
val restateVersion = libs.versions.restate.get()

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

allprojects {
apply(plugin = "com.diffplug.spotless")
apply(plugin = "com.github.jk1.dependency-license-report")
Expand Down Expand Up @@ -117,6 +111,12 @@ subprojects {
options.errorprone.excludedPaths.set(".*/build/generated/.*")
}

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

// Test platform and reporting
tasks.withType<Test> {
useJUnitPlatform()
Expand Down
8 changes: 4 additions & 4 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ plugins {
}

dependencies {
implementation(project(":sdk-java-blocking"))
implementation(project(":sdk-api"))
implementation(project(":sdk-lambda"))
implementation(project(":sdk-http-vertx"))
implementation(project(":sdk-kotlin"))
implementation(project(":sdk-api-kotlin"))
implementation(project(":sdk-serde-jackson"))

implementation(coreLibs.protobuf.java)
Expand All @@ -35,7 +35,7 @@ dependencies {

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

protobuf {
plugins {
Expand All @@ -52,7 +52,7 @@ protobuf {

generateProtoTasks {
ofSourceSet("main").forEach {
it.dependsOn(":protoc-gen-restate-java-blocking:shadowJar")
it.dependsOn(":protoc-gen-restate:shadowJar")
it.plugins {
id("grpc")
id("grpckt")
Expand Down
6 changes: 3 additions & 3 deletions examples/src/main/java/dev/restate/sdk/examples/Counter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdk.examples;

import dev.restate.sdk.blocking.RestateContext;
import dev.restate.sdk.core.CoreSerdes;
import dev.restate.sdk.core.StateKey;
import dev.restate.sdk.RestateContext;
import dev.restate.sdk.common.CoreSerdes;
import dev.restate.sdk.common.StateKey;
import dev.restate.sdk.examples.generated.*;
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder;
import org.apache.logging.log4j.LogManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
package dev.restate.sdk.examples;

import com.google.protobuf.Empty;
import dev.restate.sdk.blocking.RestateBlockingService;
import dev.restate.sdk.blocking.RestateContext;
import dev.restate.sdk.core.CoreSerdes;
import dev.restate.sdk.core.StateKey;
import dev.restate.sdk.RestateBlockingService;
import dev.restate.sdk.RestateContext;
import dev.restate.sdk.common.CoreSerdes;
import dev.restate.sdk.common.StateKey;
import dev.restate.sdk.examples.generated.*;
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder;
import io.grpc.stub.StreamObserver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
package dev.restate.sdk.examples

import com.google.protobuf.Empty
import dev.restate.sdk.core.CoreSerdes
import dev.restate.sdk.core.StateKey
import dev.restate.sdk.common.CoreSerdes
import dev.restate.sdk.common.StateKey
import dev.restate.sdk.examples.generated.*
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder
import dev.restate.sdk.kotlin.RestateCoroutineService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ plugins {
`library-publishing-conventions`
}

description = "Protoc plugin to generate interfaces compatible with dev.restate:sdk-java-blocking"
description = "Protoc plugin to generate interfaces compatible with dev.restate:sdk-api"

dependencies {
compileOnly(coreLibs.javax.annotation.api)
implementation("com.salesforce.servicelibs:jprotoc:1.2.2") {
exclude("javax.annotation", "javax.annotation-api")
}
implementation(project(":sdk-core"))
implementation(project(":sdk-common"))
}

application { mainClass.set("dev.restate.sdk.blocking.gen.JavaBlockingGen") }
application { mainClass.set("dev.restate.sdk.gen.JavaGen") }

tasks.named<ShadowJar>("shadowJar") {
// Override the default jar
Expand Down
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.blocking.gen;
package dev.restate.sdk.gen;

import com.google.common.html.HtmlEscapers;
import com.google.protobuf.DescriptorProtos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +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.blocking.gen;

import static dev.restate.sdk.blocking.gen.CodeGenUtils.*;
package dev.restate.sdk.gen;

import com.google.protobuf.DescriptorProtos;
import com.google.protobuf.compiler.PluginProtos;
Expand All @@ -23,7 +21,7 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class JavaBlockingGen extends Generator {
public class JavaGen extends Generator {

@Override
protected List<PluginProtos.CodeGeneratorResponse.Feature> supportedFeatures() {
Expand Down Expand Up @@ -93,15 +91,15 @@ private ServiceContext buildServiceContext(
DescriptorProtos.SourceCodeInfo.Location serviceLocation =
locations.stream()
.filter(
locationPathMatcher(
CodeGenUtils.locationPathMatcher(
DescriptorProtos.FileDescriptorProto.SERVICE_FIELD_NUMBER, serviceIndex))
.findFirst()
.orElseGet(DescriptorProtos.SourceCodeInfo.Location::getDefaultInstance);
serviceContext.javadoc =
getJavadoc(
getComments(serviceLocation),
CodeGenUtils.getJavadoc(
CodeGenUtils.getComments(serviceLocation),
serviceProto.getOptions().getDeprecated(),
SERVICE_INDENDATION);
CodeGenUtils.SERVICE_INDENDATION);

for (int methodIndex = 0; methodIndex < serviceProto.getMethodCount(); methodIndex++) {
serviceContext.methods.add(
Expand All @@ -118,34 +116,34 @@ private MethodContext buildMethodContext(
int serviceIndex,
int methodIndex) {
MethodContext methodContext = new MethodContext();
methodContext.methodName = mixedLower(methodProto.getName());
methodContext.methodName = CodeGenUtils.mixedLower(methodProto.getName());
// This is needed to avoid clashes with generated oneWay and delayed methods.
methodContext.topLevelClientMethodName =
(methodContext.methodName.equals("oneWay") || methodContext.methodName.equals("delayed"))
? "call" + firstUppercase(methodContext.methodName)
? "call" + CodeGenUtils.firstUppercase(methodContext.methodName)
: methodContext.methodName;
methodContext.inputType = typeMap.toJavaTypeName(methodProto.getInputType());
methodContext.isInputEmpty = isGoogleProtobufEmpty(methodProto.getInputType());
methodContext.isInputEmpty = CodeGenUtils.isGoogleProtobufEmpty(methodProto.getInputType());
methodContext.outputType = typeMap.toJavaTypeName(methodProto.getOutputType());
methodContext.isOutputEmpty = isGoogleProtobufEmpty(methodProto.getOutputType());
methodContext.isOutputEmpty = CodeGenUtils.isGoogleProtobufEmpty(methodProto.getOutputType());
methodContext.deprecated = methodProto.getOptions().getDeprecated();

// Resolve javadoc
DescriptorProtos.SourceCodeInfo.Location serviceLocation =
locations.stream()
.filter(
locationPathMatcher(
CodeGenUtils.locationPathMatcher(
DescriptorProtos.FileDescriptorProto.SERVICE_FIELD_NUMBER,
serviceIndex,
DescriptorProtos.ServiceDescriptorProto.METHOD_FIELD_NUMBER,
methodIndex))
.findFirst()
.orElseGet(DescriptorProtos.SourceCodeInfo.Location::getDefaultInstance);
methodContext.javadoc =
getJavadoc(
getComments(serviceLocation),
CodeGenUtils.getJavadoc(
CodeGenUtils.getComments(serviceLocation),
methodProto.getOptions().getDeprecated(),
METHOD_INDENDATION);
CodeGenUtils.METHOD_INDENDATION);

return methodContext;
}
Expand Down Expand Up @@ -216,15 +214,15 @@ public String methodNameUpperUnderscore() {
}

public String methodDescriptorGetter() {
return mixedLower("get_" + methodName + "_method");
return CodeGenUtils.mixedLower("get_" + methodName + "_method");
}
}

public static void main(String[] args) {
if (args.length == 0) {
ProtocPlugin.generate(List.of(new JavaBlockingGen()), List.of(Ext.serviceType));
ProtocPlugin.generate(List.of(new JavaGen()), List.of(Ext.serviceType));
} else {
ProtocPlugin.debug(List.of(new JavaBlockingGen()), List.of(Ext.serviceType), args[0]);
ProtocPlugin.debug(List.of(new JavaGen()), List.of(Ext.serviceType), args[0]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
package {{packageName}};
{{/packageName}}

import dev.restate.sdk.blocking.RestateContext;
import dev.restate.sdk.blocking.Awaitable;
import dev.restate.sdk.core.syscalls.Syscalls;
import dev.restate.sdk.RestateContext;
import dev.restate.sdk.Awaitable;
import dev.restate.sdk.common.syscalls.Syscalls;
import java.time.Duration;
import static {{packageName}}.{{serviceName}}Grpc.getServiceDescriptor;

Expand Down Expand Up @@ -93,15 +93,15 @@ public class {{className}} {
}

{{{javadoc}}}
public static abstract class {{serviceName}}RestateImplBase implements dev.restate.sdk.blocking.RestateBlockingService {
public static abstract class {{serviceName}}RestateImplBase implements dev.restate.sdk.RestateBlockingService {

{{#methods}}
{{#deprecated}}
@java.lang.Deprecated
{{/deprecated}}
{{{javadoc}}}
public {{#isOutputEmpty}}void{{/isOutputEmpty}}{{^isOutputEmpty}}{{outputType}}{{/isOutputEmpty}} {{methodName}}(RestateContext context{{^isInputEmpty}}, {{inputType}} request{{/isInputEmpty}}) throws dev.restate.sdk.core.TerminalException {
throw new dev.restate.sdk.core.TerminalException(dev.restate.sdk.core.TerminalException.Code.UNIMPLEMENTED);
public {{#isOutputEmpty}}void{{/isOutputEmpty}}{{^isOutputEmpty}}{{outputType}}{{/isOutputEmpty}} {{methodName}}(RestateContext context{{^isInputEmpty}}, {{inputType}} request{{/isInputEmpty}}) throws dev.restate.sdk.common.TerminalException {
throw new dev.restate.sdk.common.TerminalException(dev.restate.sdk.common.TerminalException.Code.UNIMPLEMENTED);
}

{{/methods}}
Expand Down
10 changes: 5 additions & 5 deletions sdk-kotlin/build.gradle.kts → sdk-api-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ plugins {
`library-publishing-conventions`
}

description = "Restate SDK Kotlin interface"
description = "Restate SDK Kotlin APIs"

dependencies {
api(project(":sdk-core"))
api(project(":sdk-common"))

implementation(kotlinLibs.kotlinx.coroutines)

testImplementation(project(":sdk-core-impl"))
testImplementation(project(":sdk-core"))
testImplementation(testingLibs.junit.jupiter)
testImplementation(testingLibs.assertj)
testImplementation(coreLibs.protobuf.java)
Expand All @@ -23,8 +23,8 @@ dependencies {
testImplementation(coreLibs.grpc.kotlin.stub)
testImplementation(coreLibs.log4j.core)

testImplementation(project(":sdk-core-impl", "testArchive"))
testProtobuf(project(":sdk-core-impl", "testArchive"))
testImplementation(project(":sdk-core", "testArchive"))
testProtobuf(project(":sdk-core", "testArchive"))
}

protobuf {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
package dev.restate.sdk.kotlin

import com.google.protobuf.ByteString
import dev.restate.sdk.core.Serde
import dev.restate.sdk.core.syscalls.DeferredResult
import dev.restate.sdk.core.syscalls.ReadyResultHolder
import dev.restate.sdk.core.syscalls.Syscalls
import dev.restate.sdk.common.Serde
import dev.restate.sdk.common.syscalls.DeferredResult
import dev.restate.sdk.common.syscalls.ReadyResultHolder
import dev.restate.sdk.common.syscalls.Syscalls
import kotlinx.coroutines.CancellableContinuation
import kotlinx.coroutines.suspendCancellableCoroutine

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
package dev.restate.sdk.kotlin

import com.google.protobuf.ByteString
import dev.restate.sdk.core.*
import dev.restate.sdk.core.syscalls.DeferredResult
import dev.restate.sdk.core.syscalls.EnterSideEffectSyscallCallback
import dev.restate.sdk.core.syscalls.ExitSideEffectSyscallCallback
import dev.restate.sdk.core.syscalls.Syscalls
import dev.restate.sdk.common.Serde
import dev.restate.sdk.common.StateKey
import dev.restate.sdk.common.TerminalException
import dev.restate.sdk.common.syscalls.DeferredResult
import dev.restate.sdk.common.syscalls.EnterSideEffectSyscallCallback
import dev.restate.sdk.common.syscalls.ExitSideEffectSyscallCallback
import dev.restate.sdk.common.syscalls.Syscalls
import io.grpc.MethodDescriptor
import java.lang.Error
import kotlin.coroutines.resume
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
package dev.restate.sdk.kotlin

import com.google.protobuf.ByteString
import dev.restate.sdk.core.Serde
import dev.restate.sdk.core.syscalls.SyscallCallback
import dev.restate.sdk.core.syscalls.Syscalls
import dev.restate.sdk.common.Serde
import dev.restate.sdk.common.syscalls.SyscallCallback
import dev.restate.sdk.common.syscalls.Syscalls
import kotlin.coroutines.resume
import kotlinx.coroutines.CancellableContinuation
import kotlinx.coroutines.CancellationException
Expand Down
Loading
Loading