[DABOM-487] processor-usage policy-updated 제거 및 global -> common 변경#57
[DABOM-487] processor-usage policy-updated 제거 및 global -> common 변경#57
Conversation
Summary of ChangesHello, 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
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Ignored Files
Activity
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
|
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Code Review
이번 PR은 policy-updated Kafka 이벤트 처리 로직을 제거하고, 전역적으로 사용되던 global 패키지를 common으로 리네이밍하는 등 대규모 리팩토링을 수행했습니다. 전반적으로 코드의 책임과 구조가 명확해진 좋은 변경입니다. 다만, 새로 추가된 설정 클래스의 어노테이션 누락과 같은 몇 가지 수정이 필요한 부분을 발견하여 코멘트를 남겼습니다. 특히, 매직 스트링 사용은 스타일 가이드에 위배되므로 수정이 필요합니다.
I am having trouble creating individual review comments. Click here to see my feedback.
src/main/java/com/project/common/config/TimeConfig.java (7)
TimeConfig 클래스가 Spring 설정 클래스로 동작하려면 @Configuration 어노테이션이 필요합니다. 현재 이 어노테이션이 없어서 clock() 메서드가 정의한 Clock Bean이 Spring 컨테이너에 등록되지 않습니다. 이로 인해 Clock Bean을 주입받는 다른 컴포넌트에서 NoSuchBeanDefinitionException이 발생할 수 있습니다.
@Configuration
src/main/java/com/project/domain/policy/helper/PolicyAssignmentSyncHelper.java (114)
limitBytes와 같은 문자열 리터럴이 코드에 직접 사용되었습니다. 이는 오타 발생 가능성을 높이고 유지보수를 어렵게 만듭니다. 스타일 가이드 12장 253라인에 따라 이러한 값들은 상수로 추출해야 합니다.
함께 수정한 PolicyConstraintMapper 클래스에 이미 LIMIT_BYTES 상수가 public static final로 정의되어 있으니, 해당 상수를 가져와 사용하는 것이 좋겠습니다. (import com.project.domain.policy.helper.PolicyConstraintMapper; 추가 필요)
이 클래스의 다른 메서드들(applyTimeBlockConstraint, applyManualBlockConstraint, applyAppBlockConstraint)에 사용된 다른 매직 스트링 ("start", "end", "reason", "blockedApps") 에도 동일하게 적용해주세요.
Long limitBytes = toPositiveLong(rules.get(PolicyConstraintMapper.LIMIT_BYTES));
References
- 매직넘버/문자열은 반드시 상수로 추출해야 합니다. (link)
src/test/java/com/project/domain/policy/infra/cache/dto/PolicyConstraintRedisHashTest.java (1-21)
이 테스트 파일이 삭제되었습니다. 삭제된 테스트(putBlockedApp_NormalizesToLowercase)는 putBlockedApp 메서드가 앱 ID를 소문자로 정규화하는 중요한 동작을 검증하고 있었습니다.
PolicyConstraintRedisHash 클래스에서 버전 관련 로직은 제거되었지만, 앱 ID 정규화 로직은 여전히 남아있습니다. 따라서 이 테스트는 삭제하는 대신, 버전 검증 로직만 제거하여 유지하는 것이 코드의 안정성을 보장하는 데 더 좋습니다.
스타일 가이드 13장 259라인에 따라, 변경된 로직에 대한 테스트 커버리지를 유지하는 것을 권장합니다.
References
- 신규 비즈니스 로직은 최소 단위 테스트 1개 이상 작성해야 합니다. 이 원칙은 기존 로직을 수정했을 때도 테스트 커버리지를 유지하는 데 적용될 수 있습니다. (link)
This comment was marked as resolved.
This comment was marked as resolved.
SonarQube Quality Summary (Community)✅ Quality Gate PASSED Branch: Issues
Measures
🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-processor-usage&branch=refactor/DABOM-487 Generated automatically by GitHub Actions. |
|
👋 PR 리마인드 알림입니다 이 PR이 몇 시간 동안 업데이트되지 않았어요.
바쁘실 수 있다는 점 이해합니다 🙏 |
🍀 이슈 & 티켓 넘버
🎯 목적
processor-usage의 policy 도메인에서policy-updatedKafka 이벤트 수신 책임을 완전히 제거dabom-api-core가 단독으로 수행하고,processor-usage는 워밍업(캐시 미스 복구)만 담당하도록 역할을 명확히 분리api-core를 원천(Source of Truth)으로 삼아 버전 필드 없는 단순 키-값 구조로 통일📝 변경 사항
PolicyKafkaConsumer,PolicyConstraintSyncService(Impl),PolicyEventValidator,PolicyConstraintEventMapper삭제PolicyUpdateStatus,PolicyConstraintKeyConstants,PolicyRuleKeyConstants삭제policy_constraint_update.lua및RedisConfig의policyConstraintUpdateScriptBean 제거PolicyConstraintRedisHash에서version파라미터 및 버전 생성 로직(putWithVersion,buildVersionField) 제거 — 해시에 직접 키-값 저장하도록 단순화PolicyAssignmentSyncHelper에서resolveAssignmentVersion제거,apply...Constraint메서드에서assignmentVersion파라미터 제거domain/policy/service/helper→domain/policy/helper로 패키지 이동PolicyConstraintEventMapper→PolicyConstraintMapper로 리네임 (이벤트 의존 불식)TimeConstants→TimeConfig로 리네임 (설정 클래스 네이밍 통일)PolicyConstraintSyncServiceImplTest,PolicyConstraintRedisHashTest삭제 및PolicyConstraintMapperTest수정global->common디렉토리 명 변경📂 변경 범위
🖥️ 주요 코드 설명
After — 버전 없는 단순 키-값 구조 (api-core와 동일)
api-core의PolicyRedisServiceImpl이HSET family:{fid}:customer:{cid}:constraints {field} {value}형식으로 저장PolicyConstraintWarmupHelper)도 동일한 키-값 구조로putAll→ Lua 스크립트가 양쪽 경로에서 동일한 해시 필드를 읽을 수 있음💬 리뷰어에게
api-core가 정책을 저장할 때와processor-usage가 워밍업할 때의 Redis 해시 필드명이 완전히 일치하는지PolicyType.getRedisKey()와RedisKeyGenerator.generateFamilyCustomerConstraintsKey()를 기준으로 확인해주시면 됩니다PolicyConstraintWarmupHelper.warmupIfMissing)가 기존 키가 있을 때 스킵하는hasKey체크가 올바른지 봐주시면 좋겠습니다PolicyConstraintSyncServiceImpl제거로 인해policy-updated토픽을 더 이상 소비하지 않으므로, Kafka consumer group offset 정리가 필요한지 운영 배포 시 확인해주시면 됩니다📋 체크리스트
기본
./gradlew build가 정상적으로 통과하는가?./gradlew spotlessApply checkstyleMain)코드 품질
Controller → Service → Repository → Entity)@Transactional은 Service에만 선언했는가?테스트
📌 참고 사항