Skip to content

Add Kotlin-spring quickstart #597

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

Merged
merged 4 commits into from
Apr 11, 2025
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
190 changes: 123 additions & 67 deletions docs/get_started/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,47 @@ import {TextAndCode} from "../../src/components/code/code/text-and-code";

# Quickstart

<Tabs groupId="sdk" queryString>
<TabItem value="ts" label="TypeScript"/>
<TabItem value="java" label="Java"/>
<TabItem value="kotlin" label="Kotlin"/>
<TabItem value="go" label="Go"/>
<TabItem value="python" label="Python"/>
<TabItem value="rust" label="Rust"/>
</Tabs>

This guide takes you through your first steps with Restate.

We will run a simple Restate Greeter service that listens on port `9080` and responds with `You said hi to <name>!` to a `greet` request.

<img src="/img/quickstart/overview.svg" alt="Quickstart" className="quickstart-image" width="400rem"/>

SDK:

<Tabs groupId="sdk" queryString className={"selection-button"}>
<TabItem value="ts" label={<><img
className="buttonIcon mb-0.5 icon"
src="/img/typescript.svg"
width="20"
/> TypeScript</>}/>
<TabItem value="java" label={<><img
className="buttonIcon mb-0.5 icon"
src="/img/java.svg"
width="20"
/> Java</>}/>
<TabItem value="kotlin" label={<><img
className="buttonIcon mb-0.5 icon"
src="/img/kotlin.svg"
width="20"
/> Kotlin</>}/>
<TabItem value="go" label={<><img
className="buttonIcon mb-0.5 icon"
src="/img/go.svg"
width="20"
/> Go </>}/>
<TabItem value="python" label={<><img
className="buttonIcon mb-0.5 icon"
src="/img/python.svg"
width="20"
/> Python </>}/>
<TabItem value="rust" label={<><img
className="buttonIcon mb-0.5 icon"
src="/img/rust.svg"
width="20"
/> Rust</>}/>
</Tabs>

<Tabs groupId="sdk" className={"display-none"}>
<TabItem value="ts" label="TypeScript">
Select your favorite runtime:
Expand Down Expand Up @@ -549,22 +575,22 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
For each request, it sent a notification, slept for a second, and then sent a reminder.
<Tabs groupId={"ts-runtime"} className={"display-none"}>
<TabItem value={"Node.js"}>
```ts
```ts https://github.com/restatedev/examples/blob/main/typescript/templates/node/src/app.ts
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/typescript/templates/node/src/app.ts
```
</TabItem>
<TabItem value={"Bun"}>
```ts
```ts https://github.com/restatedev/examples/blob/main/typescript/templates/bun/src/index.ts
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/typescript/templates/bun/src/index.ts
```
</TabItem>
<TabItem value={"Deno"}>
```ts
```ts https://github.com/restatedev/examples/blob/main/typescript/templates/deno/main.ts
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/typescript/templates/deno/main.ts
```
</TabItem>
<TabItem value={"CloudflareWorkers"} >
```ts
```ts https://github.com/restatedev/examples/blob/main/typescript/templates/cloudflare-worker/src/index.ts
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/typescript/templates/cloudflare-worker/src/index.ts
```
</TabItem>
Expand Down Expand Up @@ -621,7 +647,7 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
Build tool:
<Tabs groupId={"build-tool"} className={"selection-button"}>
<TabItem value={"maven"} label={<><img src='/img/quickstart/maven.svg' alt="Maven" className="icon" />Maven</>}>
Architecture:
Framework:
<Tabs groupId={"architecture"} className={"selection-button"}>
<TabItem value={"spring"} label={<><img src='/img/quickstart/spring.svg' alt="Spring Boot" className="icon" />Spring Boot</>}>
<Admonition type="note" title="Prerequisites">
Expand All @@ -642,7 +668,7 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
</Tabs>
</TabItem>
<TabItem value={"gradle"} label={<><img src='/img/quickstart/gradle.svg' alt="Gradle" className="icon" />Gradle</>}>
Architecture:
Framework:
<Tabs groupId={"architecture"} className={"selection-button"}>
<TabItem value={"vanilla"} label={<><img src='/img/quickstart/java.svg' alt="Vanilla" className="icon" />Vanilla</>}>
<Admonition type="note" title="Prerequisites">
Expand Down Expand Up @@ -966,26 +992,20 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
<TabItem value={"maven"}>
<Tabs groupId={"architecture"} className={"display-none"}>
<TabItem value={"spring"}>
```java
// !collapse(1:13) collapsed
// !mark[//\/\ Click to expand imports/] grey
// Click to expand imports
```java https://github.com/restatedev/examples/blob/main/java/templates/java-maven-spring-boot/src/main/java/com/example/restatestarter/Greeter.java
// collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/java/templates/java-maven-spring-boot/src/main/java/com/example/restatestarter/Greeter.java
```
</TabItem>
<TabItem value={"quarkus"}>
```java
// !collapse(1:15) collapsed
// !mark[//\/\ Click to expand imports/] grey
// Click to expand imports
```java https://github.com/restatedev/examples/blob/main/java/templates/java-maven-quarkus/src/main/java/org/acme/Greeter.java
// collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/java/templates/java-maven-quarkus/src/main/java/org/acme/Greeter.java
```
</TabItem>
<TabItem value={"vanilla"}>
```java
// !collapse(1:13) collapsed
// !mark[//\/\ Click to expand imports/] grey
// Click to expand imports
```java https://github.com/restatedev/examples/blob/main/java/templates/java-maven/src/main/java/my/example/Greeter.java
// collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/java/templates/java-maven/src/main/java/my/example/Greeter.java
```
</TabItem>
Expand All @@ -994,10 +1014,8 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
<TabItem value={"gradle"}>
<Tabs groupId={"architecture"} className={"display-none"}>
<TabItem value={"vanilla"}>
```java
// !collapse(1:13) collapsed
// !mark[//\/\ Click to expand imports/] grey
// Click to expand imports
```java https://github.com/restatedev/examples/blob/main/java/templates/java-gradle/src/main/java/my/example/Greeter.java
// collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/java/templates/java-gradle/src/main/java/my/example/Greeter.java
```
</TabItem>
Expand All @@ -1010,6 +1028,12 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
</TabItem>
<TabItem value="kotlin" label="Kotlin">

Framework:
<Tabs groupId={"architecture"} className={"selection-button"}>
<TabItem value={"spring"} label={<><img src='/img/quickstart/spring.svg' alt="Spring Boot" className="icon" />Spring Boot</>}/>
<TabItem value={"vanilla"} label={<><img src='/img/quickstart/java.svg' alt="Vanilla" className="icon" />Vanilla</>}/>
</Tabs>

<Admonition type="note" title="Prerequisites">
- [JDK](https://whichjdk.com/) >= 17
</Admonition>
Expand Down Expand Up @@ -1115,33 +1139,63 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
You can find the Restate UI running on port 9070 (`http://localhost:9070`) after starting the Restate Server.
</Step>
<Step stepLabel="2" title="Get the Greeter service template">
<Tabs groupId={"architecture"} className={"display-none"}>
<TabItem value={"spring"}>
<CodeWithTabs>

<CodeWithTabs>
```shell !!tabs CLI
restate example kotlin-hello-world-gradle-spring-boot &&
cd kotlin-hello-world-gradle-spring-boot
```

```shell !!tabs CLI
restate example kotlin-hello-world-gradle &&
cd kotlin-hello-world-gradle
```
```shell !!tabs wget
wget https://github.com/restatedev/examples/releases/latest/download/kotlin-hello-world-gradle-spring-boot.zip &&
unzip kotlin-hello-world-gradle-spring-boot.zip -d kotlin-hello-world-gradle-spring-boot &&
rm kotlin-hello-world-gradle-spring-boot.zip && cd kotlin-hello-world-gradle-spring-boot
```

```shell !!tabs wget
wget https://github.com/restatedev/examples/releases/latest/download/kotlin-hello-world-gradle.zip &&
unzip kotlin-hello-world-gradle.zip -d kotlin-hello-world-gradle &&
rm kotlin-hello-world-gradle.zip && cd kotlin-hello-world-gradle
```
</CodeWithTabs>
</TabItem>
<TabItem value={"vanilla"}>
<CodeWithTabs>

</CodeWithTabs>
```shell !!tabs CLI
restate example kotlin-hello-world-gradle &&
cd kotlin-hello-world-gradle
```

```shell !!tabs wget
wget https://github.com/restatedev/examples/releases/latest/download/kotlin-hello-world-gradle.zip &&
unzip kotlin-hello-world-gradle.zip -d kotlin-hello-world-gradle &&
rm kotlin-hello-world-gradle.zip && cd kotlin-hello-world-gradle
```

</CodeWithTabs>
</TabItem>
</Tabs>

</Step>
<Step stepLabel="3" title="Run the Greeter service">

You are all set to start developing your service.
Open the project in an IDE and configure it to build with Gradle.
Run your service and let it listen on port `9080` for requests:
<Tabs groupId={"architecture"} className={"display-none"}>
<TabItem value={"spring"}>

```shell
./gradlew run
```
```shell
./gradlew bootRun
```

</TabItem>
<TabItem value={"vanilla"}>

```shell
./gradlew run
```

</TabItem>
</Tabs>
</Step>
<Step stepLabel="4" title="Register the service">

Expand Down Expand Up @@ -1228,12 +1282,22 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
The invocation you just sent used Durable Execution to make sure the request ran till completion.
For each request, it sent a notification, slept for a second, and then sent a reminder.

```kotlin
// !collapse(1:10) collapsed
// !mark[//\/\ Click to expand imports/] grey
// Click to expand imports
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/kotlin/templates/kotlin-gradle/src/main/kotlin/my/example/Greeter.kt
```
<Tabs groupId={"architecture"} className={"display-none"}>
<TabItem value={"spring"}>
```kotlin https://github.com/restatedev/examples/blob/main/kotlin/templates/kotlin-gradle-spring-boot/src/main/kotlin/com/example/restatestarter/Greeter.kt
// collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/kotlin/templates/kotlin-gradle-spring-boot/src/main/kotlin/com/example/restatestarter/Greeter.kt
```
</TabItem>
<TabItem value={"vanilla"}>

```kotlin https://github.com/restatedev/examples/blob/main/kotlin/templates/kotlin-gradle/src/main/kotlin/my/example/Greeter.kt
// collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/kotlin/templates/kotlin-gradle/src/main/kotlin/my/example/Greeter.kt
```

</TabItem>
</Tabs>

It sometimes failed to send the notification and the reminder.
You can see in the log how Restate retried the request.
Expand Down Expand Up @@ -1466,10 +1530,8 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
The invocation you just sent used Durable Execution to make sure the request ran till completion.
For each request, it sent a notification, slept for a second, and then sent a reminder.

```go
// !collapse(1:8) collapsed
// !mark[//\/\ Click to expand imports/] grey
// Click to expand imports
```go https://github.com/restatedev/examples/blob/main/go/templates/go/greeter.go
// collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/go/templates/go/greeter.go
```

Expand Down Expand Up @@ -1722,10 +1784,8 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
The invocation you just sent used Durable Execution to make sure the request ran till completion.
For each request, it sent a notification, slept for a second, and then sent a reminder.

```python
# !collapse(1:8) collapsed
# !mark[/# Click to expand imports/] grey
# Click to expand imports
```python https://github.com/restatedev/examples/blob/main/python/templates/python/example.py
# collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/python/templates/python/example.py
```

Expand Down Expand Up @@ -2057,18 +2117,14 @@ We will run a simple Restate Greeter service that listens on port `9080` and res
For each request, it sent a notification, slept for a second, and then sent a reminder.
<Tabs groupId={"rust-runtime"} className={"display-none"}>
<TabItem value={"Tokio"}>
```rust
// !collapse(1:12) collapsed
// !mark[//\/\ Click to expand imports/] grey
// Click to expand imports
```rust https://github.com/restatedev/examples/blob/main/rust/templates/rust/src/main.rs
// collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/rust/templates/rust/src/main.rs
```
</TabItem>
<TabItem value={"Shuttle"}>
```rust
// !collapse(1:10) collapsed
// !mark[//\/\ Click to expand imports/] grey
// Click to expand imports
```rust https://github.com/restatedev/examples/blob/main/rust/templates/rust-shuttle/src/main.rs
// collapse_prequel
CODE_LOAD::https://raw.githubusercontent.com/restatedev/examples/refs/heads/main/rust/templates/rust-shuttle/src/main.rs
```
</TabItem>
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/code-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const LANGUAGE_SYMBOLS = {
},
java: {
commentSymbol: "//",
serviceSymbol: ["@Service", "@VirtualObject", "@Workflow"]
serviceSymbol: ["@Service", "@VirtualObject", "@Workflow", "@RestateService", "@RestateVirtualObject", "@RestateWorkflow"]
},
kotlin: {
commentSymbol: "//",
serviceSymbol: ["@Service", "@VirtualObject", "@Workflow"]
serviceSymbol: ["@Service", "@VirtualObject", "@Workflow", "@RestateService", "@RestateVirtualObject", "@RestateWorkflow"]
},
python: {
commentSymbol: "#",
Expand Down
Loading