Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 요약(Summary)
알림 발생 시 동적으로 Redis 배치를 생성하고 TTL(만료 시간)을 활용하는 방식을 선택했습니다.
대기 시간 최적화를 위해 초기 발생 시 TTL을 30초로 설정하되, 추가 알림 발생 시 최대 60초까지 연장하여 알림 지연을 최소화하는 전략을 적용했습니다.
단일/다중 액터를 기준으로 템플릿을 분기하여 발송합니다.
application/model/batch: batch 객체를 위한 클래스(batch, key, actor, result)를 정의했습니다.application/infra/redis: batch store 인터페이스의 구현체(redis)와 배치 dto를 구현 및 정의했습니다.application/NotificationBatchService: 배치 생성, 삭제, 조회를 담당합니다.application/NotificationBatchScheduler: 만료된 배치가 있는지 검사하여 push 발송을 트리거합니다.그 외에 payload, render, inAppWriter, publisher에 배치 관련해서 추가했습니다.
📸스크린샷 (선택)
💬 공유사항
현재 만료된 배치를 위한 Redis 스캔 시 keys 방식 대신, scan 방식으로 했습니다. 그런데 찾아보니 ZSET이나 lua같은 것도 있다고 해서, 알아본 뒤 괜찮으면 수정할 예정입니다.
또한 현재 알림 퍼블리셔에서 인앱 알림 저장(DB 작업)과 알림 발송이 한 트랜잭션에 있어서 비효율이 좀 있는 것 같아서, 이것도 알아보고 수정할 예정입니다!
✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.