[BE-04] AlertCooldownRepositoryImpl (Redis SET NX PX)
작업 내용 (설계 의도)
변경 사항
AlertCooldownRepository(BE-01 interface)를 Redis로 구현한다(ADR-003, FR-7). 근거 TDD: ../TDD.md §실패경로·§동시성.
infrastructure/alerting/redis/AlertCooldownRepositoryImpl.kt—RedisTemplate사용,tryAcquire(signal, cooldown)을opsForValue().setIfAbsent(key, "1", cooldown)(SET NX PX)로 구현. 반환 true=획득(발송 진행), false=쿨다운 중(억제).- 키는
AlertSignal.cooldownKey(env)사용(INFRA-01 계약과 1:1). - domain/application에 RedisTemplate 노출 금지(infra 격리).
의존
- BE-01 (AlertCooldownRepository interface, AlertSignal)
- INFRA-01 (키 계약)
다이어그램
처리 흐름
sequenceDiagram participant Impl as AlertCooldownRepositoryImpl participant R as Redis Impl->>R: setIfAbsent(key, "1", 15m) R-->>Impl: true(획득) / false(억제)
테스트 케이스
- 첫 tryAcquire는 true, 15분 내 동일 신호 재호출은 false를 반환한다(TestContainers Redis).
- 서로 다른 신호(source/severity 상이)는 독립적으로 각각 true를 반환한다.
- TTL 만료 후 동일 신호 재호출은 true를 반환한다.
- 동시 다중 호출에서 정확히 1건만 true를 받는다(원자성).