Skip to content

[DABOM-487] processor-usage policy-updated 제거 및 global -> common 변경#57

Merged
k0081915 merged 10 commits intodevelopfrom
refactor/DABOM-487
Mar 17, 2026
Merged

[DABOM-487] processor-usage policy-updated 제거 및 global -> common 변경#57
k0081915 merged 10 commits intodevelopfrom
refactor/DABOM-487

Conversation

@k0081915
Copy link
Member

@k0081915 k0081915 commented Mar 17, 2026

🍀 이슈 & 티켓 넘버


🎯 목적

  • processor-usage의 policy 도메인에서 policy-updated Kafka 이벤트 수신 책임을 완전히 제거
  • 정책 변경 시 Redis 갱신은 dabom-api-core가 단독으로 수행하고, processor-usage는 워밍업(캐시 미스 복구)만 담당하도록 역할을 명확히 분리
  • Redis constraints 해시 구조를 api-core를 원천(Source of Truth)으로 삼아 버전 필드 없는 단순 키-값 구조로 통일

📝 변경 사항

  • PolicyKafkaConsumer, PolicyConstraintSyncService(Impl), PolicyEventValidator, PolicyConstraintEventMapper 삭제
  • PolicyUpdateStatus, PolicyConstraintKeyConstants, PolicyRuleKeyConstants 삭제
  • policy_constraint_update.luaRedisConfigpolicyConstraintUpdateScript Bean 제거
  • PolicyConstraintRedisHash에서 version 파라미터 및 버전 생성 로직(putWithVersion, buildVersionField) 제거 — 해시에 직접 키-값 저장하도록 단순화
  • PolicyAssignmentSyncHelper에서 resolveAssignmentVersion 제거, apply...Constraint 메서드에서 assignmentVersion 파라미터 제거
  • 워밍업 헬퍼를 domain/policy/service/helperdomain/policy/helper로 패키지 이동
  • PolicyConstraintEventMapperPolicyConstraintMapper로 리네임 (이벤트 의존 불식)
  • TimeConstantsTimeConfig로 리네임 (설정 클래스 네이밍 통일)
  • PolicyConstraintSyncServiceImplTest, PolicyConstraintRedisHashTest 삭제 및 PolicyConstraintMapperTest 수정
  • global -> common 디렉토리 명 변경

📂 변경 범위

도메인 controller service repository entity infra global
policy [x] [x] [x]
usage [x]

🖥️ 주요 코드 설명

// PolicyConstraintRedisHash (이전)
public void putMonthlyLimit(long limitBytes, long version) {
    put(PolicyType.MONTHLY_LIMIT.getRedisKey(), String.valueOf(limitBytes));
    put(buildVersionField(PolicyType.MONTHLY_LIMIT.getRedisKey()), String.valueOf(version));
}
private String buildVersionField(String key) {
    return "ver:" + key;
}

After — 버전 없는 단순 키-값 구조 (api-core와 동일)

// PolicyConstraintRedisHash (이후)
public void putMonthlyLimit(long limitBytes) {
    put(PolicyType.MONTHLY_LIMIT.getRedisKey(), String.valueOf(limitBytes));
}
  • api-corePolicyRedisServiceImplHSET 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 정리가 필요한지 운영 배포 시 확인해주시면 됩니다

📋 체크리스트

기본

  • Merge 대상 브랜치가 올바른가?
  • ./gradlew build가 정상적으로 통과하는가?
  • Spotless / Checkstyle을 통과하는가? (./gradlew spotlessApply checkstyleMain)
  • 전체 변경사항이 500줄을 넘지 않는가?

코드 품질

  • 의존성 방향을 준수하는가? (Controller → Service → Repository → Entity)
  • Setter 없이 비즈니스 메서드로 상태를 변경하는가?
  • @Transactional은 Service에만 선언했는가?

테스트

  • 신규 비즈니스 로직에 대한 단위 테스트를 작성했는가?

📌 참고 사항

@github-actions github-actions bot requested a review from swthewhite March 17, 2026 11:44
@github-actions github-actions bot added size/XL PR size: XL refactor 리팩토링 style 코드 스타일 변경 labels Mar 17, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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은 processor-usage 서비스의 정책 처리 방식을 근본적으로 재정의하여, 정책 업데이트의 주도권을 dabom-api-core로 완전히 이전하고 processor-usage의 역할을 캐시 워밍업으로 한정합니다. 이를 통해 시스템 간의 책임 분리를 명확히 하고, Redis 정책 제약 조건의 데이터 모델을 단순화하여 일관성을 확보했습니다. 이 변경은 processor-usage의 복잡성을 줄이고, 정책 업데이트의 신뢰성을 향상시키는 데 기여할 것입니다.

Highlights

  • 정책 업데이트 책임 분리: processor-usage 서비스에서 policy-updated Kafka 이벤트 수신 및 처리 로직이 완전히 제거되었습니다.
  • Redis 정책 제약 조건 단순화: 정책 변경 시 Redis 갱신 책임이 dabom-api-core로 이관되었으며, processor-usage는 캐시 미스 발생 시 워밍업만 담당하도록 역할이 명확히 분리되었습니다. Redis에 저장되는 정책 제약 조건의 해시 구조가 버전 필드 없이 단순한 키-값 형태로 통일되어 api-core의 구조와 일치하게 되었습니다.
  • 패키지 구조 리팩토링: global 패키지 및 관련 파일들이 common으로 리네임되어 프로젝트 전반의 명명 규칙이 통일되었습니다.

🧠 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
  • src/main/java/com/project/common/config/TimeConfig.java
    • 새로운 TimeConfig 클래스가 추가되었습니다.
  • src/main/java/com/project/domain/customer/entity/Customer.java
    • BaseEntity의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/customer/entity/CustomerQuota.java
    • BaseEntity의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/family/entity/Family.java
    • BaseEntity의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/family/entity/FamilyMember.java
    • BaseEntity의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/family/entity/FamilyQuota.java
    • BaseEntity의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/policy/constant/PolicyConstraintKeyConstants.java
    • 파일이 제거되었습니다.
  • src/main/java/com/project/domain/policy/constant/PolicyRuleKeyConstants.java
    • 파일이 제거되었습니다.
  • src/main/java/com/project/domain/policy/entity/Policy.java
    • BaseEntityMapStringObjectConverter의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/policy/entity/PolicyAssignment.java
    • BaseEntity의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/policy/enums/PolicyType.java
    • redisKey 필드가 추가되었고
    • WEBSITE_BLOCK이 제거되었습니다.
  • src/main/java/com/project/domain/policy/enums/PolicyUpdateStatus.java
    • 파일이 제거되었습니다.
  • src/main/java/com/project/domain/policy/infra/cache/dto/PolicyConstraintRedisHash.java
    • PolicyConstraintKeyConstants import가 PolicyType으로 변경되었고
    • 버전 관리 로직(putWithVersion, buildVersionField)이 제거되었으며
    • put 메서드들이 단순화되었습니다.
  • src/main/java/com/project/domain/policy/infra/messaging/PolicyKafkaConsumer.java
    • 파일이 제거되었습니다.
  • src/main/java/com/project/domain/policy/service/PolicyConstraintSyncService.java
    • 파일이 제거되었습니다.
  • src/main/java/com/project/domain/policy/service/PolicyConstraintSyncServiceImpl.java
    • 파일이 제거되었습니다.
  • src/main/java/com/project/domain/policy/service/helper/PolicyAssignmentSyncHelper.java
    • 패키지 경로가 domain/policy/service/helper에서 domain/policy/helper로 변경되었고
    • PolicyRuleKeyConstantsTimeConstants import가 제거되었으며
    • assignmentVersion 파라미터와 resolveAssignmentVersion 메서드가 제거되었습니다.
  • src/main/java/com/project/domain/policy/service/helper/PolicyConstraintEventMapper.java
    • 파일명이 PolicyConstraintMapper.java로 변경되었고
    • 패키지 경로가 domain/policy/service/helper에서 domain/policy/helper로 변경되었으며
    • 규칙 키에 대한 상수가 추가되었고
    • normalizeValue 메서드가 PolicyType을 사용하도록 업데이트되었습니다.
  • src/main/java/com/project/domain/policy/service/helper/PolicyConstraintWarmupHelper.java
    • 패키지 경로가 domain/policy/service/helper에서 domain/policy/helper로 변경되었고
    • RedisKeyGenerator import가 업데이트되었습니다.
  • src/main/java/com/project/domain/policy/service/helper/PolicyEventValidator.java
    • 파일이 제거되었습니다.
  • src/main/java/com/project/domain/usage/entity/UsageEventOutbox.java
    • BaseEntity의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/entity/UsageRecord.java
    • BaseEntity의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/infra/messaging/UsageEventsConsumer.java
    • LogSanitizer의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/service/UsagePersistServiceImpl.java
    • TimeConstantsTimeConfig로 변경되었고
    • LogSanitizer import가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/service/UsageSyncServiceImpl.java
    • TimeConfig, LogSanitizer, RedisKeyGenerator, PolicyConstraintWarmupHelper의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/service/helper/CustomerQuotaWriter.java
    • LogSanitizer의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/service/helper/FamilyQuotaWriter.java
    • ApplicationException, FamilyErrorCode, LogSanitizer의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/service/helper/UsageFamilyMembershipCacheHelper.java
    • RedisKeyGenerator의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/service/helper/UsageLuaExecutor.java
    • LogSanitizer의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/service/helper/UsagePersistEventValidator.java
    • LogSanitizer의 import 경로가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/service/helper/UsageRecordWriter.java
    • TimeConstantsTimeConfig로 변경되었고
    • LogSanitizer import가 업데이트되었습니다.
  • src/main/java/com/project/domain/usage/service/helper/UsageRedisWarmupHelper.java
    • TimeConstantsTimeConfig로 변경되었습니다.
  • src/main/java/com/project/global/common/TimeConstants.java
    • 파일이 제거되었습니다.
  • src/main/java/com/project/global/config/CacheProperties.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/config/JpaConfig.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/config/RedisConfig.java
    • 패키지 경로가 global에서 common으로 변경되었고
    • policyConstraintUpdateScript 빈이 제거되었습니다.
  • src/main/java/com/project/global/config/ThreadPoolConfig.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/exception/ApplicationException.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/exception/BaseException.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/exception/ErrorResponse.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/exception/code/BaseErrorCode.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/exception/code/FamilyErrorCode.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/exception/code/GlobalErrorCode.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/exception/code/PolicyErrorCode.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/util/BaseEntity.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/util/LogSanitizer.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/util/MapStringObjectConverter.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/java/com/project/global/util/RedisKeyGenerator.java
    • 패키지 경로가 global에서 common으로 변경되었습니다.
  • src/main/resources/lua/policy_constraint_update.lua
    • 파일이 제거되었습니다.
  • src/test/java/com/project/domain/policy/infra/cache/dto/PolicyConstraintRedisHashTest.java
    • 파일이 제거되었습니다.
  • src/test/java/com/project/domain/policy/service/PolicyConstraintSyncServiceImplTest.java
    • 파일이 제거되었습니다.
  • src/test/java/com/project/domain/policy/service/helper/PolicyConstraintEventMapperTest.java
    • 파일명이 PolicyConstraintMapperTest.java로 변경되었고
    • 클래스명 및 import가 업데이트되었습니다.
  • src/test/java/com/project/domain/usage/infra/messaging/UsageEventsConsumerTest.java
    • LogSanitizer의 import 경로가 업데이트되었습니다.
  • src/test/java/com/project/domain/usage/service/UsagePersistServiceImplTest.java
    • LogSanitizer의 import 경로가 업데이트되었습니다.
  • src/test/java/com/project/domain/usage/service/UsageSyncServiceImplTest.java
    • LogSanitizer, RedisKeyGenerator, PolicyConstraintWarmupHelper의 import 경로가 업데이트되었습니다.
  • src/test/java/com/project/domain/usage/service/helper/FamilyQuotaWriterTest.java
    • ApplicationException, FamilyErrorCode, LogSanitizer의 import 경로가 업데이트되었습니다.
  • src/test/java/com/project/domain/usage/service/helper/UsageLuaExecutorTest.java
    • LogSanitizer의 import 경로가 업데이트되었습니다.
Ignored Files
  • Ignored by pattern: **/Q*.java (1)
    • src/main/java/com/project/common/config/QueryDslConfig.java
Activity
  • 현재까지 이 PR에 대한 특별한 리뷰 활동이나 코멘트는 없습니다.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

This comment was marked as resolved.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

critical

TimeConfig 클래스가 Spring 설정 클래스로 동작하려면 @Configuration 어노테이션이 필요합니다. 현재 이 어노테이션이 없어서 clock() 메서드가 정의한 Clock Bean이 Spring 컨테이너에 등록되지 않습니다. 이로 인해 Clock Bean을 주입받는 다른 컴포넌트에서 NoSuchBeanDefinitionException이 발생할 수 있습니다.

@Configuration

src/main/java/com/project/domain/policy/helper/PolicyAssignmentSyncHelper.java (114)

medium

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
  1. 매직넘버/문자열은 반드시 상수로 추출해야 합니다. (link)

src/test/java/com/project/domain/policy/infra/cache/dto/PolicyConstraintRedisHashTest.java (1-21)

medium

이 테스트 파일이 삭제되었습니다. 삭제된 테스트(putBlockedApp_NormalizesToLowercase)는 putBlockedApp 메서드가 앱 ID를 소문자로 정규화하는 중요한 동작을 검증하고 있었습니다.

PolicyConstraintRedisHash 클래스에서 버전 관련 로직은 제거되었지만, 앱 ID 정규화 로직은 여전히 남아있습니다. 따라서 이 테스트는 삭제하는 대신, 버전 검증 로직만 제거하여 유지하는 것이 코드의 안정성을 보장하는 데 더 좋습니다.

스타일 가이드 13장 259라인에 따라, 변경된 로직에 대한 테스트 커버리지를 유지하는 것을 권장합니다.

References
  1. 신규 비즈니스 로직은 최소 단위 테스트 1개 이상 작성해야 합니다. 이 원칙은 기존 로직을 수정했을 때도 테스트 커버리지를 유지하는 데 적용될 수 있습니다. (link)

@github-actions

This comment was marked as resolved.

@github-actions github-actions bot added the test 테스트 코드 label Mar 17, 2026
@github-actions
Copy link

SonarQube Quality Summary (Community)

Quality Gate PASSED

Branch: refactor/DABOM-487
Compared to: default branch

Issues

  • 🐞 Bugs: 7
  • 🔐 Vulnerabilities: 0
  • 📎 Code Smells: 93

Measures

  • Coverage: 0%
  • Duplication: 0%

🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-processor-usage&branch=refactor/DABOM-487

Generated automatically by GitHub Actions.

@dabom-devops-bot
Copy link

👋 PR 리마인드 알림입니다

이 PR이 몇 시간 동안 업데이트되지 않았어요.

  • 🙋 PR 작성자: 추가 작업 중이거나 설명이 필요하면 코멘트 남겨주세요
  • 👀 리뷰어 / 팀원: 이미 봤다면 LGTM 한 줄도 좋아요!

바쁘실 수 있다는 점 이해합니다 🙏
다만 작은 한 줄이 PR 흐름을 살려줘요 🙂

Copy link
Contributor

@paul0755 paul0755 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다~

@k0081915 k0081915 merged commit a29a885 into develop Mar 17, 2026
9 checks passed
@k0081915 k0081915 deleted the refactor/DABOM-487 branch March 17, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor 리팩토링 remind-needed size/XL PR size: XL style 코드 스타일 변경 test 테스트 코드

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DABOM-487] processor-usage policy-updated 제거

2 participants