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 1 commit
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
10 changes: 5 additions & 5 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:sdk-api:1.0-SNAPSHOT")
tillrohrmann marked this conversation as resolved.
Show resolved Hide resolved
```

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.sdk: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:sdk-api-kotlin:1.0-SNAPSHOT")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the above comment: dev.restate:sdk-kotlin or dev.restate:restate-sdk-kotlin would be simplest, I believe.

```

Now you need to configure the protobuf plugin to build your Protobuf contracts. For example, with Gradle (Kotlin script):
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-api-common"))
slinkydeveloper marked this conversation as resolved.
Show resolved Hide resolved
}

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
14 changes: 14 additions & 0 deletions sdk-api-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
`java-library`
`library-publishing-conventions`
}

description = "Common interfaces of the Restate SDK"

dependencies {
api(coreLibs.protobuf.java)
api(coreLibs.grpc.api)

testImplementation(testingLibs.junit.jupiter)
testImplementation(testingLibs.assertj)
}
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.core;
package dev.restate.sdk.common;

/** You MUST NOT catch this exception. */
public final class AbortedExecutionException extends Throwable {
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.core;
package dev.restate.sdk.common;

import io.grpc.BindableService;

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.core;
package dev.restate.sdk.common;

import io.grpc.BindableService;

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.core;
package dev.restate.sdk.common;

import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
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.core;
package dev.restate.sdk.common;

import io.grpc.Context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// 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.core;
package dev.restate.sdk.common;

import com.google.protobuf.ByteString;
import com.google.protobuf.UnsafeByteOperations;
import dev.restate.sdk.core.function.ThrowingFunction;
import dev.restate.sdk.common.function.ThrowingFunction;
import java.util.Objects;
import javax.annotation.Nullable;

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.core;
package dev.restate.sdk.common;

/**
* This class holds information about state's name and its type tag to be used for serializing and
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.core;
package dev.restate.sdk.common;

/** When thrown in a Restate service method, it will complete the invocation with an error. */
public class TerminalException extends RuntimeException {
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.core.function;
package dev.restate.sdk.common.function;

import java.util.function.Function;

Expand Down
Loading
Loading