Skip to content

Commit

Permalink
Add workers
Browse files Browse the repository at this point in the history
  • Loading branch information
asavershin committed May 6, 2024
1 parent f44f575 commit 24cc8ef
Show file tree
Hide file tree
Showing 32 changed files with 511 additions and 326 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ docker compose -f kafka/docker-compose.yml up --build -d

docker compose -f api/docker-compose.yml up --build -d

docker compose -f worker/docker-compose-blackwhite.yml up --build -d
docker compose -f worker/docker-compose-rotate.yml up --build -d



10 changes: 0 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@
<version>${org.projectlombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<reporting>
Expand Down
3 changes: 2 additions & 1 deletion worker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ MINIO_CONSOLE_PORT=9090
MINIO_PORT=9000

# REDIS
REDIS_HOST=redis-rotate
REDIS_HOST_ROTATE=redis-rotate
REDIS_HOST_BLACKWHITE=redis-blackwhite
REDIS_PORT=6379
REDIS_PASSWORD=cGFzc3dvcmxk
REDIS_CACHE_TIME=86400000
7 changes: 7 additions & 0 deletions worker/Dockerfile-blackwhite
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM openjdk:21

WORKDIR /app

COPY target/*.jar app.jar

CMD ["java", "-jar", "-Dspring.profiles.active=blackwhite", "app.jar"]
52 changes: 52 additions & 0 deletions worker/docker-compose-blackwhite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
networks:
kafka-net:
name: kafka-net
driver: bridge
api-net:
name: api-net
driver: bridge

services:

backend-worker-blackwhite:
container_name: backend-worker-blackwhite
networks:
- kafka-net
- api-net
build:
context: .
dockerfile: Dockerfile-blackwhite
ports:
- 8083:8081
env_file:
- .env

redis-blackwhite:
networks:
- api-net
image: redis:7.2-rc-alpine
restart: always
container_name: redis-blackwhite
ports:
- '6381:6379'
command: redis-server --save 20 1 --loglevel debug --requirepass ${REDIS_PASSWORD}
volumes:
- redis-rotate-data:/data

# minio-api:
# networks:
# - api-net
# image: minio/minio:RELEASE.2024-02-14T21-36-02Z
# container_name: minio-api
# env_file:
# - .env
# command: server ~/minio --console-address :9090
# ports:
# - '9090:9090'
# - '9000:9000'
# volumes:
# - minio-api-data:/minio

volumes:
# minio-api-data:
redis-rotate-data:
30 changes: 15 additions & 15 deletions worker/docker-compose-rotate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
context: .
dockerfile: Dockerfile-rotate
ports:
- 8081:8081
- 8082:8081
env_file:
- .env

Expand All @@ -33,20 +33,20 @@ services:
volumes:
- redis-rotate-data:/data

minio-api:
networks:
- api-net
image: minio/minio:RELEASE.2024-02-14T21-36-02Z
container_name: minio-api
env_file:
- .env
command: server ~/minio --console-address :9090
ports:
- '9090:9090'
- '9000:9000'
volumes:
- minio-api-data:/minio
# minio-api:
# networks:
# - api-net
# image: minio/minio:RELEASE.2024-02-14T21-36-02Z
# container_name: minio-api
# env_file:
# - .env
# command: server ~/minio --console-address :9090
# ports:
# - '9090:9090'
# - '9000:9000'
# volumes:
# - minio-api-data:/minio

volumes:
minio-api-data:
# minio-api-data:
redis-rotate-data:
60 changes: 60 additions & 0 deletions worker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<minio.version>8.5.7</minio.version>
<containers.version>1.19.1</containers.version>
</properties>

<dependencies>
Expand All @@ -38,6 +39,37 @@
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- REDIS-->

<!-- FOR TESTS ONLY-->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>minio</artifactId>
<version>${containers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${containers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
<!-- FOR TESTS ONLY-->
</dependencies>


Expand All @@ -55,6 +87,34 @@
</excludes>
</configuration>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.10</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>

</executions>
<configuration>
<includes>
<include>com/github/asavershin/worker/services/**</include>
<include>com/github/asavershin/worker/out/producers/**</include>
<include>com/github/asavershin/worker/in/**</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.asavershin.worker;

public class InvalidWorker extends RuntimeException {
public InvalidWorker(final String invalidWorker) {
super(invalidWorker);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.asavershin.images;
package com.github.asavershin.worker;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Loading

0 comments on commit 24cc8ef

Please sign in to comment.