Conversation
Walkthrough스케줄러가 평일 08:00–21:59 사이 30초 간격으로 SseRegistryPort.sendHeartbeat()를 호출하도록 ScheduleService에 의존성 및 작업을 추가했고, SseRegistry에 emitters 대상 하트비트 전송·에러/종료 처리 로직과 registerEmitterCallbacks 유틸이 도입되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
actor Scheduler as Scheduler
participant ScheduleService
participant SseRegistryPort
participant SseRegistry
participant Emitter
Scheduler->>ScheduleService: sseHeartbeat 트리거<br/>(평일 08:00–21:59, 30초마다)
ScheduleService->>SseRegistryPort: sendHeartbeat()
SseRegistryPort->>SseRegistry: sendHeartbeat()
SseRegistry->>SseRegistry: 등록된 emitters 반복
SseRegistry->>Emitter: send("heartbeat" event)
alt 전송 성공
Emitter-->>SseRegistry: 성공 확인
else 전송 실패 (클라이언트 중단)
Emitter-->>SseRegistry: ClientAbortException / Broken pipe
SseRegistry->>SseRegistry: completeWithError 및 emitter 제거
else 전송 실패 (기타 오류)
Emitter-->>SseRegistry: IOException 등
SseRegistry->>SseRegistry: 로그 기록 및 emitter 제거
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @ByunDohwi. * #644 (comment) The following files were modified: * `src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt` * `src/main/kotlin/dsm/pick2024/infrastructure/sse/SseRegistry.kt` * `src/main/kotlin/dsm/pick2024/infrastructure/sse/port/out/SseRegistryPort.kt`
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/main/kotlin/dsm/pick2024/infrastructure/sse/SseRegistry.kt`:
- Around line 73-76: onError 핸들러에서 emitter.complete()를 호출하면 이미
completeWithError()로 완료 중인 emitter에 대해 중복 호출이 발생할 수 있으므로 emitter.onError { ... }
내부에서 complete() 호출을 제거하고 cleanup만 수행하도록 변경하세요; 구체적으로 SseRegistry.kt의
emitter.onError 콜백에서 emitter.complete()를 삭제하고 cleanup.run()만 남기며 에러 상황은
completeWithError(error) 호출부에서만 처리되도록 유지하세요.
🧹 Nitpick comments (1)
src/main/kotlin/dsm/pick2024/infrastructure/sse/SseRegistry.kt (1)
39-47: 중복 cleanup 호출 가능성.
completeWithError(e)를 호출하면registerEmitterCallbacks()에서 등록된onError콜백이 트리거되어 이미remove()가 호출됩니다. 이후 명시적인remove()호출은 중복입니다.또한
isClientAbort()분기 로직이 로깅 외에는 동일하므로 간소화할 수 있습니다.♻️ 제안된 리팩토링
try { emitter.send(SseEmitter.event().data(data ?: ".")) } catch (e: Exception) { - if (isClientAbort(e)) { - emitter.completeWithError(e) - remove(userId, emitter) - continue + if (!isClientAbort(e)) { + logger.error("User Event Send Failed ${e.message}", e) } - logger.error("User Event Send Failed ${e.message}", e) emitter.completeWithError(e) - remove(userId, emitter) + // onError 콜백에서 cleanup이 자동으로 처리됨 }
Summary by CodeRabbit
릴리스 노트
새로운 기능
버그 수정
✏️ Tip: You can customize this high-level summary in your review settings.