[DABOM-459] family_quota 변경, 레디스 suffix 적용#54
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! 이 풀 리퀘스트는 가족 할당량 관리 시스템의 아키텍처를 개선하고 Redis 키 관리의 일관성을 강화하는 데 중점을 둡니다. 가족 할당량 데이터를 전용 엔티티로 분리하여 데이터 모델의 명확성을 높이고, 월별 데이터 정합성을 위해 Redis 키에 월별 접미사를 도입함으로써 시스템의 안정성과 확장성을 향상시켰습니다. 또한, 관련 서비스 로직과 캐싱 메커니즘을 업데이트하여 새로운 구조를 지원하도록 변경했습니다. 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
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
안녕하세요. 전반적으로 family 테이블의 사용량 집계 책임을 family_quota 테이블로 성공적으로 분리하고, 관련 Redis 키 구조를 월별 suffix({yyyyMM}) 기반으로 통일한 좋은 리팩토링이라고 생각합니다. 특히 FamilyQuotaWriter에 update-insert-retry 패턴을 적용하여 동시성 문제를 안정적으로 처리한 점이 인상적입니다.
리뷰에서는 주로 프로젝트 스타일 가이드 준수와 코드 가독성 개선에 초점을 맞추었습니다. 몇 가지 제안 사항을 코멘트로 남겼으니 확인 부탁드립니다.
스타일 가이드 요약
리뷰는 다음 저장소 스타일 가이드 규칙을 기반으로 작성되었습니다:
- 예외 처리(규칙 6, 14):
RuntimeException이나IllegalStateException대신ApplicationException과ErrorCode를 사용해야 합니다. - Entity(규칙 10):
BaseEntity를 상속받는 엔티티의updatedAt필드는 JPA Auditing을 통해 자동으로 관리되어야 합니다.
SonarQube Quality Summary (Community)✅ Quality Gate PASSED Branch: Issues
Measures
🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-processor-usage&branch=fix/DABOM-459 Generated automatically by GitHub Actions. |
SonarQube Quality Summary (Community)✅ Quality Gate PASSED Branch: Issues
Measures
🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-processor-usage&branch=fix/DABOM-459 Generated automatically by GitHub Actions. |
|
👋 PR 리마인드 알림입니다 이 PR이 몇 시간 동안 업데이트되지 않았어요.
바쁘실 수 있다는 점 이해합니다 🙏 |
🍀 이슈 & 티켓 넘버
🎯 목적
family테이블에 섞여 있던 월별 가족 사용량 집계 책임을family_quota로 분리processor-usage의 family Redis 키를 모두{yyyyMM}suffix 기반으로 통일해 월경계 정합성을 높임eventMonth를 기준으로 동작하도록 맞춤📝 변경 사항
Family엔티티에서totalQuotaBytes,usedBytes,currentMonth의존을 제거FamilyQuota,FamilyQuotaRepository,FamilyQuotaWriter를 추가하고 허용 이벤트 집계를family_quotaupsert로 전환UsagePersistServiceImpl가 허용 이벤트에서family_quota를 갱신하고 차단 이벤트에서는 기존처럼customer_quota만 반영하도록 정리RedisKeyGenerator,UsageSyncServiceImpl,UsageRedisWarmupHelper,UsageLuaExecutor,usage_update.lua를 월 suffix 키 구조로 변경family + family_quota조합으로info,remaining을 시드하도록 수정FamilyCacheRepository,FamilyCacheDto,familyCacheRedisTemplate,FamilyUsageWriter를 제거UsageSyncServiceImplTest,UsagePersistServiceImplTest,UsageLuaExecutorTest를 수정하고FamilyQuotaWriterTest,UsageRedisWarmupHelperTest를 추가📂 변경 범위
🖥️ 주요 코드 설명
FamilyQuotaWriter는 현재 월 row가 있으면update로 끝내고 없으면 최신family_quota스냅샷의totalQuotaBytes를 복사해 새 월 row를 생성한다DataIntegrityViolationException이후update를 다시 시도해 복구한다UsageSyncServiceImpl는eventTime에서 계산한eventMonth를info,remaining,alert,customer monthly usage키 전부에 공통으로 사용한다UsageRedisWarmupHelper는 현재 월family_quota가 없으면 최신 스냅샷으로info와remaining을 시드해 월초 첫 이벤트를 처리할 수 있게 한다usage_update.lua는 alert prefix를 조합하지 않고family:{fid}:alert:THRESHOLD:{threshold}:{yyyyMM}완성 키를 직접 받아 같은 달 같은 임계치 알림만 한 번 발행한다💬 리뷰어에게
FamilyQuotaWriter의update -> insert -> retry update패턴과 월 suffix Redis key contract가 잘 적용됐는지 확인해주시면 됩니다📋 체크리스트
기본
./gradlew build가 정상적으로 통과하는가?./gradlew spotlessApply checkstyleMain)코드 품질
Controller → Service → Repository → Entity)@Transactional은 Service에만 선언했는가?테스트
📌 참고 사항