이미지 결과 조회 시퀀스 수정: Redis 캐시 제거하고 Event DB 직접 조회로 변경

This commit is contained in:
doyeon 2025-10-23 10:25:48 +09:00
parent ae23b27f58
commit ff0cad6c57

View File

@ -4,42 +4,50 @@
title Event Service - 이미지 생성 결과 폴링 조회
participant "EventController" as Controller <<C>>
participant "JobService" as JobSvc <<S>>
participant "Redis Cache" as Cache <<E>>
participant "EventService" as EventSvc <<S>>
participant "EventRepository" as EventRepo <<R>>
participant "Event DB" as EventDB <<D>>
note over Controller: GET /api/jobs/{jobId}/status
Controller -> JobSvc: getJobStatus(jobId)
activate JobSvc
note over Controller: GET /api/events/{eventId}/status
Controller -> EventSvc: 이미지 생성 결과 조회 요청\n(이벤트ID)
activate EventSvc
JobSvc -> Cache: get("job:" + jobId)
activate Cache
EventSvc -> EventRepo: 이벤트 조회\n(이벤트ID)
activate EventRepo
alt 캐시 히트
Cache --> JobSvc: Job data\n{status, result, createdAt}
EventRepo -> EventDB: 이벤트 정보 조회
activate EventDB
alt Job 완료 (status: COMPLETED)
JobSvc --> Controller: JobStatusResponse\n{jobId, status: COMPLETED,\nimageUrls: {...}}
Controller --> Client: 200 OK\n{status: COMPLETED,\nimageUrls: {\n simple: "https://cdn.../simple.png",\n fancy: "https://cdn.../fancy.png",\n trendy: "https://cdn.../trendy.png"\n}}
alt 이벤트 존재
EventDB --> EventRepo: 이벤트 엔티티\n{이벤트ID, 상태, 이미지URL들,\n생성일시}
deactivate EventDB
EventRepo --> EventSvc: Event 엔티티
else Job 진행중 (status: PROCESSING)
JobSvc --> Controller: JobStatusResponse\n{jobId, status: PROCESSING,\nprogress: 33%}
Controller --> Client: 200 OK\n{status: PROCESSING,\nprogress: 33%}
alt 이미지 생성 완료 (상태: COMPLETED)
EventSvc --> Controller: 완료 응답\n{이벤트ID, 상태: 완료,\n이미지URL들}
Controller --> Client: 200 OK\n{상태: 완료,\n이미지URL들: {\n 심플형: "https://cdn.../simple.png",\n 화려형: "https://cdn.../fancy.png",\n 트렌디형: "https://cdn.../trendy.png"\n}}
else 이미지 생성중 (상태: PROCESSING)
EventSvc --> Controller: 진행중 응답\n{이벤트ID, 상태: 처리중,\n진행률: 33%}
Controller --> Client: 200 OK\n{상태: 처리중,\n진행률: 33%}
note right: 클라이언트는 3초 후\n재요청
else Job 실패 (status: FAILED)
JobSvc --> Controller: JobStatusResponse\n{jobId, status: FAILED, error}
Controller --> Client: 200 OK\n{status: FAILED, error}
else 이미지 생성 실패 (상태: FAILED)
EventSvc --> Controller: 실패 응답\n{이벤트ID, 상태: 실패,\n오류메시지}
Controller --> Client: 200 OK\n{상태: 실패,\n오류메시지}
end
else 캐시 미스
Cache --> JobSvc: null
JobSvc --> Controller: NotFoundError
Controller --> Client: 404 Not Found\n{error: "Job not found"}
else 이벤트 미존재
EventDB --> EventRepo: null
deactivate EventDB
EventRepo --> EventSvc: null
EventSvc --> Controller: 미발견 오류
Controller --> Client: 404 Not Found\n{오류: "이벤트를 찾을 수 없음"}
end
deactivate Cache
deactivate JobSvc
deactivate EventRepo
deactivate EventSvc
note over Controller, Cache: 최대 30초 동안 폴링\n(3초 간격, 최대 10회)\n\n타임아웃 시 클라이언트는\n에러 메시지 표시 및\n"다시 생성" 옵션 제공
note over Controller, EventDB: 최대 30초 동안 폴링\n(3초 간격, 최대 10회)\n\n타임아웃 시 클라이언트는\n에러 메시지 표시 및\n"다시 생성" 옵션 제공
@enduml