Skip to content

Commit

Permalink
Update SDKS to more modern version (#116)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rberrelleza authored Sep 16, 2024
1 parent efca18b commit 0323b2c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .oktetoignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
.github
.vscode
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/okteto/movies

go 1.17
go 1.22

require github.com/lib/pq v1.10.5

Expand Down
2 changes: 1 addition & 1 deletion catalog/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:20

WORKDIR /src

Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16 AS dev
FROM node:20 AS dev

# setup okteto message
COPY bashrc /root/.bashrc
Expand Down
16 changes: 14 additions & 2 deletions rent/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
FROM maven:3.8.1-jdk-11
FROM maven:3.9.8-eclipse-temurin-21

WORKDIR /app
COPY . .

# copy the project files
COPY ./pom.xml ./pom.xml


# build all dependencies for offline use
RUN mvn dependency:go-offline -B

# copy the src files
COPY ./src ./src

# build for release
RUN mvn clean package

RUN cp ./target/*.jar app.jar

EXPOSE 8080
Expand Down
6 changes: 3 additions & 3 deletions rent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>
<version>3.3.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.okteto</groupId>
Expand All @@ -14,7 +14,7 @@
<name>rent</name>
<description>Rent backend service for Movies App</description>
<properties>
<java.version>11</java.version>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>3.2.21</version>
<version>3.4.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
27 changes: 8 additions & 19 deletions rent/src/main/java/com/okteto/rent/controller/RentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
Expand All @@ -34,29 +31,21 @@ Map<String, String> healthz() {
}

@PostMapping(path= "/rent", consumes = "application/json", produces = "application/json")
List<String> rent(@RequestBody Rent rentInput, HttpServletResponse response) {
List<String> rent(@RequestBody Rent rentInput) {
String catalogID = rentInput.getMovieID();
String price = rentInput.getPrice();

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

ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(KAFKA_TOPIC, catalogID, price);

future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
@Override
public void onSuccess(SendResult<String, String> result) {
logger.info("Message [{}] delivered with offset {}",
catalogID,
result.getRecordMetadata().offset());
}

@Override
public void onFailure(Throwable ex) {
logger.warn("Unable to deliver message [{}]. {}",
kafkaTemplate.send(KAFKA_TOPIC, catalogID, price)
.thenAccept(result -> logger.info("Message [{}] delivered with offset {}",
catalogID,
ex.getMessage());
}
result.getRecordMetadata().offset()))
.exceptionally(ex -> {
logger.warn("Unable to deliver message [{}]. {}", catalogID, ex.getMessage());
return null;
});


return new LinkedList<>();
}
Expand Down
2 changes: 1 addition & 1 deletion worker/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/okteto/movies

go 1.17
go 1.22

require (
github.com/Shopify/sarama v1.32.0
Expand Down

0 comments on commit 0323b2c

Please sign in to comment.