Skip to content

Commit ecfcc50

Browse files
committed
Kubernetes and Spring cloud gateway added
1 parent 29aa06d commit ecfcc50

File tree

23 files changed

+234
-278
lines changed

23 files changed

+234
-278
lines changed

.idea/compiler.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 49 additions & 189 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose-base.yml renamed to docker/docker-compose-base.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
course:
3-
build: microservices/course-service
3+
build: ../microservices/course-service
44
mem_limit: 512m
55
environment:
66
- SPRING_PROFILES_ACTIVE=docker
@@ -11,7 +11,7 @@ services:
1111
# condition: service_healthy
1212

1313
review:
14-
build: microservices/review-service
14+
build: ../microservices/review-service
1515
mem_limit: 512m
1616
environment:
1717
- SPRING_PROFILES_ACTIVE=docker
@@ -22,7 +22,7 @@ services:
2222
# condition: service_healthy
2323

2424
course-composite:
25-
build: microservices/course-composite-service
25+
build: ../microservices/course-composite-service
2626
mem_limit: 512m
2727
ports:
2828
- "8080:8080"
@@ -31,6 +31,16 @@ services:
3131
networks:
3232
- shared-network
3333

34+
gateway-service:
35+
build: ../spring-cloud/gateway-service
36+
mem_limit: 512m
37+
ports:
38+
- "9000:9000"
39+
environment:
40+
- SPRING_PROFILES_ACTIVE=docker
41+
networks:
42+
- shared-network
43+
3444
networks:
3545
shared-network:
3646
name: shared-network

docker-compose-infra.yml renamed to docker/docker-compose-infra.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ services:
2626
timeout: 5s
2727
retries: 5
2828
start_period: 30s
29+
volumes:
30+
- ./postgresql/init.sql:/docker-entrypoint-initdb.d/init.sql
2931
networks:
3032
- shared-network
3133
networks:

docker/postgresql/init.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DO $$
2+
BEGIN
3+
IF NOT EXISTS (SELECT FROM pg_database WHERE datname = 'course_db') THEN
4+
CREATE DATABASE course_db;
5+
END IF;
6+
END $$;

microservices/course-composite-service/src/main/java/io/javatab/microservices/composite/course/CourseCompositeServiceApplication.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
@ComponentScan({"io.javatab"})
1111
public class CourseCompositeServiceApplication {
1212

13-
@Bean
14-
RestTemplate restTemplate() {
15-
return new RestTemplate();
16-
}
17-
1813
public static void main(String[] args) {
1914
SpringApplication.run(CourseCompositeServiceApplication.class, args);
2015
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.javatab.microservices.composite.course.web;
2+
3+
import lombok.Data;
4+
5+
@Data
6+
public class Course {
7+
private Long id;
8+
private String title;
9+
private String author;
10+
private Double price;
11+
private String publisher;
12+
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package io.javatab.microservices.composite.course.web;
22

33

4+
import lombok.Builder;
5+
import lombok.Data;
6+
47
import java.util.List;
58

9+
@Data
10+
@Builder
611
public class CourseAggregate {
7-
private Long id;
8-
private String title;
9-
private String author;
10-
private Double price;
11-
private String publisher;
12+
private Course course;
1213
private List<Review> reviews;
1314
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.javatab.microservices.composite.course.web;
2+
3+
import io.javatab.util.http.NetworkUtility;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.RestController;
11+
import reactor.core.publisher.Mono;
12+
13+
import java.util.List;
14+
15+
@RestController
16+
@RequestMapping("/api/course-aggregate")
17+
public class CourseAggregateController {
18+
19+
private static final Logger logger = LoggerFactory.getLogger(CourseAggregateController.class);
20+
21+
22+
private final CourseCompositeIntegration integration;
23+
private final NetworkUtility utility;
24+
25+
public CourseAggregateController(CourseCompositeIntegration integration, NetworkUtility utility) {
26+
this.integration = integration;
27+
this.utility = utility;
28+
}
29+
30+
@GetMapping("/{id}/with-details")
31+
public Mono<CourseAggregate> getCourses(@PathVariable Long id) {
32+
logger.info("Fetching course and review details for course id : {}", id);
33+
return integration.getCourseDetails(id);
34+
}
35+
}

0 commit comments

Comments
 (0)