Skip to content

Commit 5578d1f

Browse files
committed
fix: java 17 for event sourced counter sample
1 parent 0f2f48c commit 5578d1f

File tree

8 files changed

+25
-70
lines changed

8 files changed

+25
-70
lines changed

samples/spring-eventsourced-counter/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ With both the proxy and your application running, once you have defined endpoint
3838

3939
- increase (or create) a counter named `hello` with value `10`
4040
```shell
41-
curl -i -XPOST localhost:9000/counter/hello/increase/10
41+
curl -XPOST localhost:9000/counter/hello/increase/10
4242
```
4343

4444
- retrieve the value of a counter named `hello`
4545
```shell
46-
curl -i -XGET localhost:9000/counter/hello
46+
curl -XGET localhost:9000/counter/hello
4747
```
4848

4949
- multiply existing counter named `hello` by value `5`
5050
```shell
51-
curl -i -XPOST localhost:9000/counter/hello/multiply/5
51+
curl -XPOST localhost:9000/counter/hello/multiply/5
5252
```
5353

5454
### Deploy

samples/spring-eventsourced-counter/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
1717
<mainClass>com.example.Main</mainClass>
1818

19-
<jdk.target>11</jdk.target>
19+
<jdk.target>17</jdk.target>
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2121

2222
<kalix-sdk.version>1.0.8</kalix-sdk.version>
@@ -91,7 +91,7 @@
9191
<name>${dockerImage}:%l</name>
9292
<build>
9393
<!-- Base Docker image which contains jre-->
94-
<from>docker.io/library/adoptopenjdk:${jdk.target}-jre-hotspot</from>
94+
<from>docker.io/library/eclipse-temurin:${jdk.target}-alpine</from>
9595
<createImageOptions>
9696
<platform>linux/amd64</platform>
9797
</createImageOptions>

samples/spring-eventsourced-counter/src/main/java/com/example/Counter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import org.springframework.web.bind.annotation.PostMapping;
2727
import org.springframework.web.bind.annotation.RequestMapping;
2828

29+
import static com.example.CounterEvent.ValueIncreased;
30+
import static com.example.CounterEvent.ValueMultiplied;
31+
2932
@Entity(entityKey = "id", entityType = "counter")
3033
@RequestMapping("/counter/{id}")
3134
public class Counter extends EventSourcedEntity<Integer> {
@@ -58,12 +61,12 @@ public Effect<String> multiply(@PathVariable Integer value) {
5861

5962
@EventHandler
6063
public Integer handleIncrease(ValueIncreased value) {
61-
return currentState() + value.value;
64+
return currentState() + value.value();
6265
}
6366

6467
@EventHandler
6568
public Integer handleMultiply(ValueMultiplied value) {
66-
return currentState() * value.value;
69+
return currentState() * value.value();
6770
}
6871
}
6972

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.example;
2+
3+
public sealed interface CounterEvent {
4+
5+
record ValueIncreased(int value) implements CounterEvent {
6+
}
7+
8+
record ValueMultiplied(int value) implements CounterEvent {
9+
}
10+
}

samples/spring-eventsourced-counter/src/main/java/com/example/ValueIncreased.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

samples/spring-eventsourced-counter/src/main/java/com/example/ValueMultiplied.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

samples/spring-eventsourced-counter/src/test/java/com/example/CounterTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import kalix.javasdk.testkit.EventSourcedResult;
44
import kalix.springsdk.testkit.EventSourcedTestKit;
5-
import org.junit.jupiter.api.Assertions;
65
import org.junit.jupiter.api.Test;
76

7+
import static com.example.CounterEvent.ValueIncreased;
8+
import static com.example.CounterEvent.ValueMultiplied;
89
import static org.junit.jupiter.api.Assertions.assertEquals;
910
import static org.junit.jupiter.api.Assertions.assertTrue;
1011

samples/spring-fibonacci-action/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<properties>
1212

1313
<!-- TODO Update to your own Docker repository or Docker Hub scope -->
14-
<dockerImage>my-docker-repo/${project.artifactId}</dockerImage>
14+
<dockerImage>aludwiko/${project.artifactId}</dockerImage>
1515
<dockerTag>${project.version}-${build.timestamp}</dockerTag>
1616
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
1717
<mainClass>com.example.Main</mainClass>
@@ -307,12 +307,12 @@
307307
<dependency>
308308
<groupId>io.kalix</groupId>
309309
<artifactId>kalix-spring-sdk</artifactId>
310-
<version>${kalix-sdk.version}</version>
310+
<version>1.0.8-14-fedc8579-dev-SNAPSHOT</version>
311311
</dependency>
312312
<dependency>
313313
<groupId>io.kalix</groupId>
314314
<artifactId>kalix-spring-sdk-testkit</artifactId>
315-
<version>${kalix-sdk.version}</version>
315+
<version>1.0.8-14-fedc8579-dev-SNAPSHOT</version>
316316
<scope>test</scope>
317317
</dependency>
318318

0 commit comments

Comments
 (0)