Skip to content

Dev#266

Merged
Misu0616 merged 6 commits into
mainfrom
dev
Mar 17, 2026
Merged

Dev#266
Misu0616 merged 6 commits into
mainfrom
dev

Conversation

@ms-0o0
Copy link
Copy Markdown
Contributor

@ms-0o0 ms-0o0 commented Mar 17, 2026

개요

관련 BackLog

Resolves: (Backlog Number, ...)

PR 유형

  • 새로운 기능 추가
  • 버그 수정
  • CSS 등 사용자 UI 디자인 변경
  • 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)
  • 코드 리팩토링
  • 주석 추가 및 수정
  • 문서 수정
  • 테스트 추가, 테스트 리팩토링
  • 빌드 부분 혹은 패키지 매니저 수정
  • 파일 혹은 폴더명 수정
  • 파일 혹은 폴더 삭제

PR Checklist

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

Summary by CodeRabbit

  • New Features

    • Added Redis AOF (Append-Only File) backup configuration and management for cache Redis instance
    • Added ability to toggle repeat block policy active/inactive status via new API endpoint
  • Documentation

    • Added comprehensive AOF backup configuration guide with setup scenarios and operational guidance
  • Tests

    • Added test coverage for AOF backup service initialization and repeat block policy toggle functionality

@ms-0o0 ms-0o0 requested a review from Misu0616 March 17, 2026 07:16
@ms-0o0 ms-0o0 self-assigned this Mar 17, 2026
@ms-0o0 ms-0o0 added feature 새 기능 개발 priority: midium 우선순위: 중 labels Mar 17, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5a8c2c43-1ce9-42c2-9970-563a555724eb

📥 Commits

Reviewing files that changed from the base of the PR and between 3207276 and 60da082.

📒 Files selected for processing (14)
  • docs/cache-redis-aof-backup.md
  • src/main/java/com/pooli/common/config/CacheRedisAofBackupService.java
  • src/main/java/com/pooli/common/config/CacheRedisConfig.java
  • src/main/java/com/pooli/common/config/CacheRedisProperties.java
  • src/main/java/com/pooli/policy/controller/UserPolicyController.java
  • src/main/java/com/pooli/policy/domain/dto/request/BlockPolicyUpdateReqDto.java
  • src/main/java/com/pooli/policy/domain/dto/response/BlockPolicyResDto.java
  • src/main/java/com/pooli/policy/mapper/RepeatBlockMapper.java
  • src/main/java/com/pooli/policy/service/UserPolicyService.java
  • src/main/java/com/pooli/policy/service/UserPolicyServiceImpl.java
  • src/main/resources/application.yaml
  • src/main/resources/mapper/policy/RepeatBlockMapper.xml
  • src/test/java/com/pooli/common/config/CacheRedisAofBackupServiceTest.java
  • src/test/java/com/pooli/policy/service/UserPolicyServiceImplTest.java

📝 Walkthrough

Walkthrough

This PR adds Redis AOF backup configuration management for the cache Redis instance with a startup validation service, and introduces an endpoint and service methods to toggle repeat-block policy activation status. DTOs are updated with field renames for consistency (enabled → isActive).

Changes

Cohort / File(s) Summary
AOF Backup Documentation & Configuration
docs/cache-redis-aof-backup.md, src/main/resources/application.yaml
Adds AOF backup guide and default configuration properties (enabled, appendfsync, rewrite settings, fail-fast behavior) under app.redis.cache.aof namespace.
AOF Backup Service & Setup
src/main/java/com/pooli/common/config/CacheRedisAofBackupService.java, src/main/java/com/pooli/common/config/CacheRedisProperties.java, src/main/java/com/pooli/common/config/CacheRedisConfig.java
Introduces CacheRedisAofBackupService to validate and apply AOF settings at startup, with AofProperties binding configuration and ApplicationRunner bean integration for boot-time execution.
AOF Service Tests
src/test/java/com/pooli/common/config/CacheRedisAofBackupServiceTest.java
Validates AOF setup with mocked Redis interactions, covering disabled/enabled states, configuration application, rewrite, and fail-fast behavior.
Repeat Block Policy Toggle
src/main/java/com/pooli/policy/controller/UserPolicyController.java, src/main/java/com/pooli/policy/service/UserPolicyService.java, src/main/java/com/pooli/policy/service/UserPolicyServiceImpl.java
Adds new PATCH endpoint and service methods to toggle repeat-block activation status with authorization checks, state synchronization, and audit logging.
Policy DTO & Mapper Updates
src/main/java/com/pooli/policy/domain/dto/request/BlockPolicyUpdateReqDto.java, src/main/java/com/pooli/policy/domain/dto/response/BlockPolicyResDto.java, src/main/java/com/pooli/policy/mapper/RepeatBlockMapper.java, src/main/resources/mapper/policy/RepeatBlockMapper.xml
Renames DTO field from enabled to isActive for consistency; adds updateIsActive mapper method for database-level state updates.
Policy Toggle Tests
src/test/java/com/pooli/policy/service/UserPolicyServiceImplTest.java
Adds test coverage for repeat-block toggle functionality, validating successful state changes, mapper persistence, and not-found error handling.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application<br/>(Startup)
    participant Config as CacheRedisConfig
    participant Service as CacheRedisAofBackupService
    participant Redis as Redis Instance
    participant Log as Logger

    App->>Config: Boot ApplicationRunner
    Config->>Service: Invoke ensureAofReady()
    
    alt AOF Enabled
        Service->>Service: Validate requested settings
        
        opt ConfigureOnStartup
            Service->>Redis: CONFIG SET (appendonly, appendfsync, etc)
            Redis-->>Service: ACK
            
            opt RewriteConfigOnStartup
                Service->>Redis: CONFIG REWRITE
                Redis-->>Service: ACK
            end
        end
        
        Service->>Redis: CONFIG GET (verify settings)
        Redis-->>Service: Current AOF state
        Service->>Service: Compare & validate
        
        opt FailFast Validation Failure
            Service->>Log: Throw IllegalStateException
        end
        
        opt TriggerBackgroundRewrite
            Service->>Redis: BGREWRITEAOF
            Redis-->>Service: ACK
        end
        
        Service->>Log: Log readiness status
    else AOF Disabled
        Service->>Log: Log skip message
    end
    
    Service-->>App: Complete
Loading
sequenceDiagram
    participant Client as Client
    participant Controller as UserPolicyController
    participant Service as UserPolicyService
    participant Mapper as RepeatBlockMapper
    participant DB as Database
    participant Cache as Redis Cache
    participant Audit as AuditHistory

    Client->>Controller: PATCH /api/policies/lines/repeat-block/enable-toggles
    Controller->>Service: toggleRepeatBlockPolicy(id, request, auth)
    
    Service->>Mapper: Fetch repeat block by id
    Mapper->>DB: SELECT repeat_block
    DB-->>Mapper: Block record
    Mapper-->>Service: Block data
    
    Service->>Service: Validate family-group access
    Service->>Service: Toggle isActive state
    
    Service->>Mapper: updateIsActive(id, isActive)
    Mapper->>DB: UPDATE is_active, updated_at
    DB-->>Mapper: Success
    Mapper-->>Service: Rows affected
    
    Service->>Audit: Create alarm history
    Audit->>DB: INSERT alarm record
    
    Service->>Cache: Refresh blocks (write-through)
    Cache-->>Service: ACK
    
    Service->>Audit: Log policy history
    Audit->>DB: INSERT history record
    
    Service->>Controller: Return BlockPolicyResDto
    Controller-->>Client: 200 OK (updated policy)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • [MERGE] dev to main #162: Introduces cache Redis configuration infrastructure (CacheRedisConfig, CacheRedisProperties) that this PR builds upon for AOF startup initialization.
  • Dev to main #217: Overlaps with policy service and mapper modifications for repeat-block policy toggling logic.
  • [MERGE] dev to main #165: Modifies the same test file (UserPolicyServiceImplTest) with related policy test coverage.

Suggested labels

documentation, test

Suggested reviewers

  • Misu0616
  • pjh813

Poem

🐰 Redis backed up with AOF so bright, ✨
Policies toggle left and right,
Startup checks the config with care,
Mapped updates travel everywhere,
All the data flows so right! 🚀

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@Misu0616 Misu0616 left a comment

Choose a reason for hiding this comment

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

merge 확인

@Misu0616 Misu0616 merged commit 1329c37 into main Mar 17, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 새 기능 개발 priority: midium 우선순위: 중

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants