π Refactor : λͺ¨λλ¬ λͺ¨λλ¦¬μ€ λ³κ²½μ μν λ©ν°λͺ¨λ μ€μ #264
Conversation
Summary of ChangesHello @tkv00, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! μ΄ PRμ νλ‘μ νΈλ₯Ό λͺ¨λλ¬ λͺ¨λλ¦¬μ€ μν€ν
μ²λ‘ 리ν©ν λ§νλ κ²μ λͺ©νλ‘ ν©λλ€. μ΄λ₯Ό μν΄ μ½λλ² μ΄μ€λ₯Ό Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with π and π on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
μ΄ PRμ κΈ°μ‘΄μ λͺ¨λ리μ μ ν리μΌμ΄μ
μ λͺ¨λλ¬ λͺ¨λλ¦¬μ€ κ΅¬μ‘°λ‘ λ¦¬ν©ν°λ§νλ μ€μν λ³κ²½ μ¬νμ λ΄κ³ μμ΅λλ€. νλ‘μ νΈ κ΅¬μ‘°λ₯Ό appsμ domainsλ‘ λλμ΄ κ° λͺ¨λμ μ±
μκ³Ό μν μ λͺ
νν λΆλ¦¬ν μ μ΄ μΈμμ μ
λλ€. Gradle λΉλ μ€ν¬λ¦½νΈμ Docker μ€μ λ μλ‘μ΄ κ΅¬μ‘°μ λ§κ² μ μμ λμμ΅λλ€.
μ λ°μ μΌλ‘ ꡬ쑰μ μΈ κ°μ μ΄ λ보μ΄μ§λ§, λͺ κ°μ§ μΉλͺ μ μΈ μ€μ μ€λ₯μ κ°μ μ΄ νμν λΆλΆμ΄ λ°κ²¬λμμ΅λλ€. νΉν, YAML νμΌμ λ¬Έλ² μ€λ₯μ Docker μ€μ λλ½μ μ ν리μΌμ΄μ μ μ μμ μΈ μ€νμ λ°©ν΄ν μ μμΌλ―λ‘ λ°λμ μμ μ΄ νμν©λλ€. λν, μ£Όμ μ²λ¦¬λ μ±λ‘ λ¨μμλ νμΌλ€μ μ½λλ² μ΄μ€μ νΌλμ μΌκΈ°ν μ μμΌλ―λ‘ μ 리νλ κ²μ΄ μ’κ² μ΅λλ€. μλμ κ° νμΌλ³λ‘ μμΈν 리뷰 λ΄μ©μ μ 리νμ΅λλ€.
| @@ -0,0 +1,5 @@ | |||
| spring: | |||
| @@ -0,0 +1,5 @@ | |||
| spring: | |||
| max-request-size: 5000MB | ||
|
|
||
| config: | ||
| import: -elasticsearch.yml |
There was a problem hiding this comment.
| condition: service_healthy | ||
| networks: | ||
| - spring-network | ||
| restart: always |
There was a problem hiding this comment.
api-server μλΉμ€μ healthcheck μ€μ μ΄ λλ½λμμ΅λλ€. ν¬μ€μ²΄ν¬λ 컨ν
μ΄λμ μνλ₯Ό λͺ¨λν°λ§νκ³ λΉμ μ μνμΌ λ μλμΌλ‘ μ¬μμνλ λ± μλΉμ€ μμ μ±μ μν΄ νμμ μ
λλ€. Spring Boot Actuatorμ health endpointλ₯Ό μ¬μ©νλ ν¬μ€μ²΄ν¬λ₯Ό μΆκ°νλ κ²μ κ°λ ₯ν κΆμ₯ν©λλ€.
restart: always
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/actuator/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s| elasticsearch: | ||
| enabled: false |
There was a problem hiding this comment.
Elasticsearch health checkκ° global μ€μ μμ λΉνμ±νλμ΄ μμ΅λλ€. api-serverμ κ°μ΄ Elasticsearchλ₯Ό μ¬μ©νλ λͺ¨λμμλ health checkκ° νμ±νλμ΄μΌ μλΉμ€μ μ°κ²° μνλ₯Ό μ¬λ°λ₯΄κ² λͺ¨λν°λ§ν μ μμ΅λλ€. es νλ‘νκ³Ό κ°μ΄ Elasticsearchλ₯Ό μ¬μ©νλ νλ‘νμμλ μ΄ μ€μ μ trueλ‘ μ€λ²λΌμ΄λνμ¬ νμ±ννλ κ²μ΄ μ’μ΅λλ€.
| COPY apps apps | ||
| COPY domains domains | ||
|
|
||
|
|
||
| RUN chmod +x gradlew | ||
|
|
||
| ARG MODULE_NAME=api-server | ||
|
|
||
| RUN ./gradlew :apps:${MODULE_NAME}:bootJar --no-daemon -x test |
There was a problem hiding this comment.
Docker λΉλ μ λ μ΄μ΄ μΊμλ₯Ό λ ν¨μ¨μ μΌλ‘ νμ©νκΈ° μν΄ μμ‘΄μ±μ λ¨Όμ λ€μ΄λ‘λνκ³ μμ€ μ½λλ₯Ό 볡μ¬νλ λ°©μμΌλ‘ λ³κ²½νλ κ²μ μ μν©λλ€. νμ¬ κ΅¬μ‘°μμλ μμ€ μ½λκ° λ³κ²½λ λλ§λ€ λ§€λ² μμ‘΄μ±μ μλ‘ λ€μ΄λ‘λν΄μΌ νλ―λ‘ λΉλ μκ°μ΄ κΈΈμ΄μ§ μ μμ΅λλ€.
μμ‘΄μ± κ΄λ ¨ νμΌ(build.gradle, settings.gradle λ±)μ λ¨Όμ 볡μ¬νμ¬ ./gradlew dependenciesμ κ°μ λͺ
λ ΉμΌλ‘ μμ‘΄μ±μ λ€μ΄λ‘λν ν, μμ€ μ½λλ₯Ό 볡μ¬νλ©΄ μμ€ μ½λλ§ λ³κ²½λμμ λ μμ‘΄μ± λ μ΄μ΄λ₯Ό μΊμμμ μ¬μ¬μ©ν μ μμ΄ λΉλ μλλ₯Ό ν¬κ² ν₯μμν¬ μ μμ΅λλ€.
μΆμ²νλ ꡬ쑰λ λ€μκ³Ό κ°μ΅λλ€.
# ... build files copy
COPY build.gradle settings.gradle ./
COPY gradle gradle
COPY gradlew ./
# Grant execute permission
RUN chmod +x gradlew
# Download dependencies to leverage cache
RUN ./gradlew dependencies --no-daemon
# Copy source code
COPY apps apps
COPY domains domains
# Build application
ARG MODULE_NAME=api-server
RUN ./gradlew :apps:${MODULE_NAME}:bootJar --no-daemon -x test| networks: | ||
| - spring-network |
There was a problem hiding this comment.
batch-server μλΉμ€μ healthcheckκ° μμ΄ μλΉμ€μ μνλ₯Ό νμΈν μ μμ΅λλ€. λ°°μΉ μμ
μ΄ μ€ν¨νκ±°λ 컨ν
μ΄λκ° λΉμ μ μνκ° λμ΄λ κ°μ§νκΈ° μ΄λ ΅μ΅λλ€. κ°λ¨ν healthcheckλΌλ μΆκ°νμ¬ μ»¨ν
μ΄λμ μ μ λμ μ¬λΆλ₯Ό νμΈν μ μλλ‘ νλ κ²μ΄ μ’μ΅λλ€. Spring Boot Actuatorκ° μλ€λ©΄ μ΄λ₯Ό νμ©ν μ μμ΅λλ€.
| //package com.shootpointer.config.ranking; | ||
| // | ||
| //import com.shootpointer.dto.HighlightWithMemberDto; | ||
| //import com.shootpointer.listener.ranking.RankingJobExecutionListener; | ||
| //import com.shootpointer.listener.ranking.RankingStepExecutionListener; | ||
| //import com.shootpointer.processor.ranking.RankingProcessor; | ||
| //import com.shootpointer.validator.RankingValidator; | ||
| //import com.shootpointer.writer.ranking.RankingWriter; | ||
| //import com.shootpointer.domain.ranking.entity.RankingDocument; | ||
| //import lombok.RequiredArgsConstructor; | ||
| //import org.springframework.batch.core.Job; | ||
| //import org.springframework.batch.core.Step; | ||
| //import org.springframework.batch.core.configuration.annotation.StepScope; | ||
| //import org.springframework.batch.core.job.builder.JobBuilder; | ||
| //import org.springframework.batch.core.repository.JobRepository; | ||
| //import org.springframework.batch.core.step.builder.StepBuilder; | ||
| //import org.springframework.batch.item.database.JdbcPagingItemReader; | ||
| //import org.springframework.context.annotation.Bean; | ||
| //import org.springframework.context.annotation.Configuration; | ||
| //import org.springframework.context.annotation.Profile; | ||
| //import org.springframework.transaction.PlatformTransactionManager; | ||
| // | ||
| //@Configuration | ||
| //@RequiredArgsConstructor | ||
| //@Profile("batch") | ||
| //public class RankingBatchConfig { | ||
| // private final JobRepository jobRepository; | ||
| // private final RankingProcessor rankingProcessor; | ||
| // private final RankingWriter rankingWriter; | ||
| // private final RankingValidator validator; | ||
| // private final PlatformTransactionManager transactionManager; | ||
| // /** | ||
| // * Page Size | ||
| // */ | ||
| // private final int PAGE_SIZE=1_000; | ||
| // | ||
| // @Bean | ||
| // public Job rankingJob(Step rankingStep){ | ||
| // return new JobBuilder("RankingJob",jobRepository) | ||
| // .listener(new RankingJobExecutionListener()) | ||
| // .validator(validator) | ||
| // .start(rankingStep) | ||
| // .build(); | ||
| // } | ||
| // | ||
| // @Bean | ||
| // @StepScope | ||
| // public Step rankingStep(JdbcPagingItemReader<HighlightWithMemberDto> highlightReader){ | ||
| // return new StepBuilder("RankingStep",jobRepository) | ||
| // .<HighlightWithMemberDto, RankingDocument>chunk(PAGE_SIZE,transactionManager) | ||
| // .listener(new RankingStepExecutionListener()) | ||
| // .reader(highlightReader) | ||
| // .processor(rankingProcessor) | ||
| // .writer(rankingWriter) | ||
| // .build(); | ||
| // } | ||
| // | ||
| //} | ||
| // | ||
| // |
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
|
||
| @SpringBootApplication(scanBasePackages = "com.shootpointer") |
There was a problem hiding this comment.
λͺ¨λλ¬ λͺ¨λλ¦¬μ€ κ΅¬μ‘°μμλ κ° domain λͺ¨λμ΄ λ
립μ μΌλ‘ μ»΄ν¬λνΈ μ€μΊμ μνν μ μλλ‘ μ€μ νλ κ²μ΄ μ’μ΅λλ€. @SpringBootApplication(scanBasePackages = "com.shootpointer")μ κ°μ΄ μμ ν¨ν€μ§λ₯Ό μ€μΊνλ©΄ λͺ¨λ domainμ μ»΄ν¬λνΈκ° λ±λ‘λμ΄ λͺ¨λ κ° κ²°ν©λκ° λμμ§ μ μμ΅λλ€.
ApiServerApplicationμ΄ μμΉν ν¨ν€μ§(com.shootpointer)λ₯Ό κΈ°λ³Έ μ€μΊ ν¨ν€μ§λ‘ μ¬μ©νκ³ , κ° domain λͺ¨λμμλ @ComponentScanμ΄λ @EnableAutoConfigurationμ ν΅ν΄ νμν μ»΄ν¬λνΈλ§ λ
ΈμΆνλλ‘ κ΅¬μ±νλ κ²μ κ³ λ €ν΄ λ³΄μΈμ. μ΄λ κ² νλ©΄ λͺ¨λμ μμ¨μ±μ΄ λμμ§κ³ μμ‘΄μ± κ΄λ¦¬κ° μ©μ΄ν΄μ§λλ€.
| COPY --from=builder /shootpointer/apps/${MODULE_NAME}/build/libs/*.jar app.jar | ||
|
|
||
| # μ€ν | ||
| ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul", "-jar", "/app/app.jar"] No newline at end of file |
There was a problem hiding this comment.
ENTRYPOINT κ²½λ‘κ° /app/app.jarλ‘ λμ΄ μλλ°, WORKDIRκ° /appμΌλ‘ μ€μ λμ΄ μμΌλ―λ‘ μλ κ²½λ‘μΈ app.jarλ‘ μ§μ νλ κ²μ΄ λ κ°κ²°νκ³ μΌλ°μ μ
λλ€. νμ¬ μ½λλ λμμλ λ¬Έμ κ° μμ§λ§, κ°λ
μ±κ³Ό μΌκ΄μ±μ μν΄ μμ μ κ³ λ €ν΄ λ³΄μΈμ.
ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul", "-jar", "app.jar"]
π μ΄μ λ²νΈ
β μμ μ¬ν
β¨ κΈ°ν