Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Add Java tour examples (#12)
Browse files Browse the repository at this point in the history
* Tour of Restate Java

* Line up Typescript tour with Java tour

---------

Co-authored-by: Giselle van Dongen <[email protected]>
  • Loading branch information
pcholakov and gvdongen authored Dec 13, 2023
1 parent 8c99a40 commit dd44782
Show file tree
Hide file tree
Showing 60 changed files with 1,313 additions and 128 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

jobs:
build:
build-ts:
# prevent from running on forks
if: github.repository_owner == 'restatedev'
runs-on: ubuntu-latest
Expand All @@ -23,5 +23,30 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm ci
working-directory: typescript
- run: npm run verify
working-directory: typescript

build-java:
# prevent from running on forks
if: github.repository_owner == 'restatedev'
runs-on: ubuntu-latest
strategy:
matrix:
jvm-version: [ 17 ]

steps:
- uses: actions/checkout@v3

- name: Use JVM ${{ matrix.jvm-version }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.jvm-version }}

- name: Test java tour
uses: gradle/gradle-build-action@v2
with:
arguments: check
build-root-directory: java
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
node_modules/
dist/

.idea
**/.idea
.vscode

npm-debug.log*
*.tsbuildinfo
.npm
.eslintcache

# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

.idea
*.iml
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
[![Discord](https://img.shields.io/discord/1128210118216007792?logo=discord)](https://discord.gg/skW3AZ6uGd)
[![Twitter](https://img.shields.io/twitter/follow/restatedev.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=restatedev)

# A Tour of Restate: Typescript handler API
# A Tour of Restate

Restate is a system for easily building resilient applications using **distributed durable RPC & async/await**.

This repository contains the code examples for the `Tour of Restate` tutorial.
This repository contains the code examples for the `Tour of Restate` tutorial, for the Typescript Handler API and Java SDK.
This tutorial takes your through key Restate features by developing an end-to-end ticketing app.

❓ Learn more about Restate from the [Restate documentation](https://docs.restate.dev).
Expand All @@ -16,14 +16,14 @@ Have a look at the [Tour of Restate tutorial](https://docs.restate.dev/tour) in

## Releasing

In order to create a new release, push a tag of the form `vX.Y.Z`.
To create a new release, push a tag of the form `vX.Y.Z`.
Then [create a release via GitHub](https://github.com/restatedev/tour-of-restate-typescript/releases).

Releases of this repository are referred to by the [documentation](https://github.com/restatedev/documentation).
Please update the version tag referenced on the [Tour of Restate](https://github.com/restatedev/documentation/blob/main/docs/tour.mdx) documentation page.

### Upgrading Typescript SDK
Upgrade the version tag in `package.json` and rerun the different parts of the tutorial:
Upgrade the version tag in `typescript/package.json` and rerun the different parts of the tutorial:
```
npm install
npm run build
Expand All @@ -35,3 +35,15 @@ npm run part4
```

An SDK upgrade warrants a new release.


### Upgrading Java SDK
Upgrade the version tag in `java/build.gradle.kts` and rerun the different parts of the tutorial:

```typescript
./gradlew run
./gradlew -PmainClass=dev.restate.tour.part1.AppMain run
./gradlew -PmainClass=dev.restate.tour.part2.AppMain run
./gradlew -PmainClass=dev.restate.tour.part3.AppMain run
./gradlew -PmainClass=dev.restate.tour.part4.AppMain run
```
65 changes: 65 additions & 0 deletions java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import com.google.protobuf.gradle.id

plugins {
java
application

id("com.google.protobuf") version "0.9.1"
}

repositories {
mavenCentral()
// OSSRH Snapshots repo
// TODO remove it once we have the proper release
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
}

val restateSdkVersion = "0.0.1-SNAPSHOT"

dependencies {
// Restate SDK
implementation("dev.restate:sdk-api:$restateSdkVersion")
implementation("dev.restate:sdk-http-vertx:$restateSdkVersion")
// To use Jackson to read/write state entries (optional)
implementation("dev.restate:sdk-serde-jackson:$restateSdkVersion")

// Protobuf and grpc dependencies
implementation("com.google.protobuf:protobuf-java:3.24.3")
implementation("io.grpc:grpc-stub:1.58.0")
implementation("io.grpc:grpc-protobuf:1.58.0")
// This is needed to compile the @Generated annotation forced by the grpc compiler
// See https://github.com/grpc/grpc-java/issues/9153
compileOnly("org.apache.tomcat:annotations-api:6.0.53")

// Logging (optional)
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
}

// Configure protoc plugin
protobuf {
protoc { artifact = "com.google.protobuf:protoc:3.24.3" }

// We need both grpc and restate codegen(s) because the restate codegen depends on the grpc one
plugins {
id("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:1.58.0" }
id("restate") { artifact = "dev.restate:protoc-gen-restate:$restateSdkVersion:all@jar" }
}

generateProtoTasks {
all().forEach {
it.plugins {
id("grpc")
id("restate")
}
}
}
}

// Set main class
application {
if (project.hasProperty("mainClass")) {
mainClass.set(project.property("mainClass") as String);
} else {
mainClass.set("dev.restate.tour.app.AppMain")
}
}
Binary file added java/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions java/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit dd44782

Please sign in to comment.