Skip to content
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 .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: 'adopt'

- name: Setup Gradle
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [ 11, 17, 21 ]
java: [ 17, 21 ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ We know that your time is precious and, therefore, deeply value any effort to co

Prerequisites:

- JDK >= 11
- JDK >= 17
- Docker or Podman

To build the SDK:
Expand Down
6 changes: 0 additions & 6 deletions admin-client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import net.ltgt.gradle.errorprone.errorprone
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask

plugins {
Expand Down Expand Up @@ -48,11 +47,6 @@ tasks.withType<GenerateTask> {
finalizedBy("spotlessJava")
}

tasks.withType<JavaCompile>().configureEach {
// Disable errorprone for this module
options.errorprone.disableAllChecks.set(true)
}

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
java { targetExclude(fileTree("build/generate-resources") { include("**/*.java") }) }
}
5 changes: 2 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ repositories {


dependencies {
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.0.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
implementation("org.jetbrains.kotlin:kotlin-serialization:2.0.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21")
implementation("org.jetbrains.kotlin:kotlin-serialization:2.0.21")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
}
21 changes: 1 addition & 20 deletions buildSrc/src/main/kotlin/java-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@

import net.ltgt.gradle.errorprone.errorprone

plugins {
java
id("net.ltgt.errorprone")
id("com.diffplug.spotless")
}

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

// Configure the java toolchain to use. If not found, it will be downloaded automatically
java {
toolchain { languageVersion = JavaLanguageVersion.of(11) }
toolchain { languageVersion = JavaLanguageVersion.of(17) }

withJavadocJar()
withSourcesJar()
}

tasks.withType<JavaCompile>().configureEach {
options.errorprone.disableWarningsInGeneratedCode.set(true)
options.errorprone.disable(
// We use toString() in proto messages for debugging reasons.
"LiteProtoToString",
// This check is proposing to use a guava API instead...
"StringSplitter",
// This is conflicting with a javadoc warn lint
"MissingSummary"
)
options.errorprone.excludedPaths.set(".*/build/generated/.*")
}

tasks.withType<Test> { useJUnitPlatform() }

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

java {
toolchain { languageVersion = JavaLanguageVersion.of(11) }
toolchain { languageVersion = JavaLanguageVersion.of(17) }

withJavadocJar()
withSourcesJar()
Expand Down
43 changes: 1 addition & 42 deletions examples/src/main/java/my/restate/sdk/examples/Counter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ public long get(SharedObjectContext ctx) {
return ctx.get(TOTAL).orElse(0L);
}

/** Get the current counter value. */
@Shared
@Handler
public Node getNode(SharedObjectContext ctx) {
return null;
}

/** Add a value, and get both the previous value and the new value. */
@Handler
public CounterUpdateResult getAndAdd(ObjectContext ctx, long request) {
Expand All @@ -71,39 +64,5 @@ public static void main(String[] args) {
RestateHttpEndpointBuilder.builder().bind(new Counter()).buildAndListen();
}

public static class Node {
private final String data;
private final Node inner;

public Node(String data, Node inner) {
this.data = data;
this.inner = inner;
}

public String getData() {
return data;
}

public Node getInner() {
return inner;
}
}

public static class CounterUpdateResult {
private final long newValue;
private final long oldValue;

public CounterUpdateResult(long newValue, long oldValue) {
this.newValue = newValue;
this.oldValue = oldValue;
}

public long getNewValue() {
return newValue;
}

public long getOldValue() {
return oldValue;
}
}
public record CounterUpdateResult(long newValue, long oldValue) {}
}
63 changes: 4 additions & 59 deletions examples/src/main/java/my/restate/sdk/examples/LoanWorkflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package my.restate.sdk.examples;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import dev.restate.sdk.Context;
import dev.restate.sdk.JsonSerdes;
import dev.restate.sdk.SharedWorkflowContext;
Expand Down Expand Up @@ -45,41 +43,8 @@ public enum Status {
TRANSFER_FAILED
}

public static class LoanRequest {

private final String customerName;
private final String customerId;
private final String customerBankAccount;
private final BigDecimal amount;

@JsonCreator
public LoanRequest(
@JsonProperty("customerName") String customerName,
@JsonProperty("customerId") String customerId,
@JsonProperty("customerBankAccount") String customerBankAccount,
@JsonProperty("amount") BigDecimal amount) {
this.customerName = customerName;
this.customerId = customerId;
this.customerBankAccount = customerBankAccount;
this.amount = amount;
}

public String getCustomerName() {
return customerName;
}

public String getCustomerId() {
return customerId;
}

public String getCustomerBankAccount() {
return customerBankAccount;
}

public BigDecimal getAmount() {
return amount;
}
}
public record LoanRequest(
String customerName, String customerId, String customerBankAccount, BigDecimal amount) {}

private static final Logger LOG = LogManager.getLogger(LoanWorkflow.class);

Expand Down Expand Up @@ -123,8 +88,7 @@ public String run(WorkflowContext ctx, LoanRequest loanRequest) {
executionTime =
bankClient
.transfer(
new TransferRequest(
loanRequest.getCustomerBankAccount(), loanRequest.getAmount()))
new TransferRequest(loanRequest.customerBankAccount(), loanRequest.amount()))
.await(Duration.ofDays(7));
} catch (TerminalException | TimeoutException e) {
LOG.warn("Transaction failed", e);
Expand Down Expand Up @@ -223,24 +187,5 @@ public Instant transfer(Context context, TransferRequest request) throws Termina
}
}

public static class TransferRequest {
private final String bankAccount;
private final BigDecimal amount;

@JsonCreator
public TransferRequest(
@JsonProperty("bankAccount") String bankAccount,
@JsonProperty("amount") BigDecimal amount) {
this.bankAccount = bankAccount;
this.amount = amount;
}

public String getBankAccount() {
return bankAccount;
}

public BigDecimal getAmount() {
return amount;
}
}
public record TransferRequest(String bankAccount, BigDecimal amount) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,13 @@
import java.util.Objects;
import org.jspecify.annotations.Nullable;

public class Handler {

private final CharSequence name;
private final HandlerType handlerType;
private final @Nullable String inputAccept;
private final PayloadType inputType;
private final PayloadType outputType;
private final @Nullable String documentation;

public Handler(
CharSequence name,
HandlerType handlerType,
@Nullable String inputAccept,
PayloadType inputType,
PayloadType outputType,
@Nullable String documentation) {
this.name = name;
this.handlerType = handlerType;
this.inputAccept = inputAccept;
this.inputType = inputType;
this.outputType = outputType;
this.documentation = documentation;
}

public CharSequence getName() {
return name;
}

public HandlerType getHandlerType() {
return handlerType;
}

@Nullable
public String getInputAccept() {
return inputAccept;
}

public PayloadType getInputType() {
return inputType;
}

public PayloadType getOutputType() {
return outputType;
}

public @Nullable String getDocumentation() {
return documentation;
}
public record Handler(
CharSequence name,
HandlerType handlerType,
@Nullable String inputAccept,
PayloadType inputType,
PayloadType outputType,
@Nullable String documentation) {

public static Builder builder() {
return new Builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public enum HandlerType {
SHARED,
EXCLUSIVE,
STATELESS,
WORKFLOW;
WORKFLOW
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,4 @@
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdk.gen.model;

import java.util.Objects;

public class PayloadType {

private final boolean isEmpty;
private final String name;
private final String boxed;
private final String serdeDecl;

public PayloadType(boolean isEmpty, String name, String boxed, String serdeDecl) {
this.isEmpty = isEmpty;
this.name = name;
this.boxed = boxed;
this.serdeDecl = serdeDecl;
}

public boolean isEmpty() {
return isEmpty;
}

public String getName() {
return name;
}

public String getBoxed() {
return boxed;
}

public String getSerdeDecl() {
return serdeDecl;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PayloadType)) return false;
PayloadType that = (PayloadType) o;
return isEmpty == that.isEmpty
&& Objects.equals(name, that.name)
&& Objects.equals(boxed, that.boxed)
&& Objects.equals(serdeDecl, that.serdeDecl);
}

@Override
public int hashCode() {
return Objects.hash(name, boxed, serdeDecl);
}

@Override
public String toString() {
return "PayloadType{"
+ "name='"
+ name
+ '\''
+ ", boxed='"
+ boxed
+ '\''
+ ", serdeDecl='"
+ serdeDecl
+ '\''
+ '}';
}
}
public record PayloadType(boolean isEmpty, String name, String boxed, String serdeDecl) {}
Loading
Loading