Skip to content

Commit 0323b2c

Browse files
authored
Update SDKS to more modern version (#116)
* update API and Worker to go 1.22 * Update catalog and frontend to node 20 * upgrade to java 22, maven 3.8, and springbooot 3.x * remove unused imports on restcontroller
1 parent efca18b commit 0323b2c

File tree

8 files changed

+32
-28
lines changed

8 files changed

+32
-28
lines changed

.oktetoignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
.github
3+
.vscode

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/okteto/movies
22

3-
go 1.17
3+
go 1.22
44

55
require github.com/lib/pq v1.10.5
66

catalog/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16
1+
FROM node:20
22

33
WORKDIR /src
44

frontend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16 AS dev
1+
FROM node:20 AS dev
22

33
# setup okteto message
44
COPY bashrc /root/.bashrc

rent/Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
FROM maven:3.8.1-jdk-11
1+
FROM maven:3.9.8-eclipse-temurin-21
22

33
WORKDIR /app
4-
COPY . .
4+
5+
# copy the project files
6+
COPY ./pom.xml ./pom.xml
7+
8+
9+
# build all dependencies for offline use
10+
RUN mvn dependency:go-offline -B
11+
12+
# copy the src files
13+
COPY ./src ./src
14+
15+
# build for release
516
RUN mvn clean package
17+
618
RUN cp ./target/*.jar app.jar
719

820
EXPOSE 8080

rent/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.5.6</version>
8+
<version>3.3.2</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.okteto</groupId>
@@ -14,7 +14,7 @@
1414
<name>rent</name>
1515
<description>Rent backend service for Movies App</description>
1616
<properties>
17-
<java.version>11</java.version>
17+
<java.version>21</java.version>
1818
</properties>
1919
<dependencies>
2020
<dependency>
@@ -48,7 +48,7 @@
4848
<dependency>
4949
<groupId>ognl</groupId>
5050
<artifactId>ognl</artifactId>
51-
<version>3.2.21</version>
51+
<version>3.4.3</version>
5252
</dependency>
5353
<dependency>
5454
<groupId>org.springframework.boot</groupId>

rent/src/main/java/com/okteto/rent/controller/RentController.java

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.kafka.core.KafkaTemplate;
88
import org.springframework.kafka.support.SendResult;
9-
import org.springframework.util.concurrent.ListenableFuture;
10-
import org.springframework.util.concurrent.ListenableFutureCallback;
119
import org.springframework.web.bind.annotation.PostMapping;
1210
import org.springframework.web.bind.annotation.GetMapping;
1311
import org.springframework.web.bind.annotation.RequestBody;
1412
import org.springframework.web.bind.annotation.RestController;
1513

16-
import javax.servlet.http.HttpServletResponse;
1714
import java.util.LinkedList;
1815
import java.util.List;
1916
import java.util.Map;
@@ -34,29 +31,21 @@ Map<String, String> healthz() {
3431
}
3532

3633
@PostMapping(path= "/rent", consumes = "application/json", produces = "application/json")
37-
List<String> rent(@RequestBody Rent rentInput, HttpServletResponse response) {
34+
List<String> rent(@RequestBody Rent rentInput) {
3835
String catalogID = rentInput.getMovieID();
3936
String price = rentInput.getPrice();
4037

4138
logger.info("Rent [{},{}] received", catalogID, price);
4239

43-
ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(KAFKA_TOPIC, catalogID, price);
44-
45-
future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
46-
@Override
47-
public void onSuccess(SendResult<String, String> result) {
48-
logger.info("Message [{}] delivered with offset {}",
49-
catalogID,
50-
result.getRecordMetadata().offset());
51-
}
52-
53-
@Override
54-
public void onFailure(Throwable ex) {
55-
logger.warn("Unable to deliver message [{}]. {}",
40+
kafkaTemplate.send(KAFKA_TOPIC, catalogID, price)
41+
.thenAccept(result -> logger.info("Message [{}] delivered with offset {}",
5642
catalogID,
57-
ex.getMessage());
58-
}
43+
result.getRecordMetadata().offset()))
44+
.exceptionally(ex -> {
45+
logger.warn("Unable to deliver message [{}]. {}", catalogID, ex.getMessage());
46+
return null;
5947
});
48+
6049

6150
return new LinkedList<>();
6251
}

worker/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/okteto/movies
22

3-
go 1.17
3+
go 1.22
44

55
require (
66
github.com/Shopify/sarama v1.32.0

0 commit comments

Comments
 (0)