mirror of
https://github.com/ktds-dg0501/kt-event-marketing.git
synced 2025-12-06 10:06:24 +00:00
redis 추가
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
fa4c09e865
commit
9ee2178b57
@ -202,20 +202,12 @@ else 캐시 MISS (새로운 이미지 생성)
|
|||||||
JobStatus --> Handler: 업데이트 완료
|
JobStatus --> Handler: 업데이트 완료
|
||||||
deactivate JobStatus
|
deactivate JobStatus
|
||||||
|
|
||||||
== Kafka 이벤트 발행 (이미지 생성 완료) ==
|
|
||||||
note over Handler: Kafka 이벤트 발행하여\nEvent Service에 결과 전달
|
|
||||||
|
|
||||||
Handler -> Consumer: Kafka 이벤트 발행
|
|
||||||
activate Consumer
|
|
||||||
Consumer -> Consumer: Kafka Producer로\nevent-topic 발행\nContentCreated\n{jobId, eventDraftId, imageUrls}
|
|
||||||
note right
|
|
||||||
Event Service는 Kafka Consumer로
|
|
||||||
ContentCreated 이벤트를 구독하여
|
|
||||||
Event DB에 이미지 URL 저장
|
|
||||||
end note
|
|
||||||
deactivate Consumer
|
|
||||||
|
|
||||||
Handler --> Consumer: 처리 완료
|
Handler --> Consumer: 처리 완료
|
||||||
|
note over Handler
|
||||||
|
이미지 URL은 Redis에만 저장됨
|
||||||
|
Event Service는 폴링을 통해
|
||||||
|
Redis에서 결과 조회
|
||||||
|
end note
|
||||||
end
|
end
|
||||||
|
|
||||||
deactivate Handler
|
deactivate Handler
|
||||||
|
|||||||
@ -4,50 +4,42 @@
|
|||||||
title Event Service - 이미지 생성 결과 폴링 조회
|
title Event Service - 이미지 생성 결과 폴링 조회
|
||||||
|
|
||||||
participant "EventController" as Controller <<C>>
|
participant "EventController" as Controller <<C>>
|
||||||
participant "EventService" as EventSvc <<S>>
|
participant "JobService" as JobSvc <<S>>
|
||||||
participant "EventRepository" as EventRepo <<R>>
|
participant "Redis Cache" as Cache <<E>>
|
||||||
participant "Event DB" as EventDB <<D>>
|
|
||||||
|
|
||||||
note over Controller: GET /api/events/{eventId}/status
|
note over Controller: GET /api/jobs/{jobId}/images
|
||||||
Controller -> EventSvc: 이미지 생성 결과 조회 요청\n(이벤트ID)
|
Controller -> JobSvc: getImageJobStatus(jobId)
|
||||||
activate EventSvc
|
activate JobSvc
|
||||||
|
|
||||||
EventSvc -> EventRepo: 이벤트 조회\n(이벤트ID)
|
JobSvc -> Cache: get("job:" + jobId)
|
||||||
activate EventRepo
|
activate Cache
|
||||||
|
|
||||||
EventRepo -> EventDB: 이벤트 정보 조회
|
alt 캐시 히트
|
||||||
activate EventDB
|
Cache --> JobSvc: Job data\n{status, imageUrls, createdAt}
|
||||||
|
|
||||||
alt 이벤트 존재
|
alt Job 완료 (status: COMPLETED)
|
||||||
EventDB --> EventRepo: 이벤트 엔티티\n{이벤트ID, 상태, 이미지URL들,\n생성일시}
|
JobSvc --> Controller: JobStatusResponse\n{jobId, status: COMPLETED,\nimageUrls: {...}}
|
||||||
deactivate EventDB
|
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}}
|
||||||
EventRepo --> EventSvc: Event 엔티티
|
|
||||||
|
|
||||||
alt 이미지 생성 완료 (상태: COMPLETED)
|
else Job 진행중 (status: PROCESSING)
|
||||||
EventSvc --> Controller: 완료 응답\n{이벤트ID, 상태: 완료,\n이미지URL들}
|
JobSvc --> Controller: JobStatusResponse\n{jobId, status: PROCESSING}
|
||||||
Controller --> Client: 200 OK\n{상태: 완료,\n이미지URL들: {\n 심플형: "https://cdn.../simple.png",\n 화려형: "https://cdn.../fancy.png",\n 트렌디형: "https://cdn.../trendy.png"\n}}
|
Controller --> Client: 200 OK\n{status: PROCESSING}
|
||||||
|
|
||||||
else 이미지 생성중 (상태: PROCESSING)
|
|
||||||
EventSvc --> Controller: 진행중 응답\n{이벤트ID, 상태: 처리중,\n진행률: 33%}
|
|
||||||
Controller --> Client: 200 OK\n{상태: 처리중,\n진행률: 33%}
|
|
||||||
note right: 클라이언트는 3초 후\n재요청
|
note right: 클라이언트는 3초 후\n재요청
|
||||||
|
|
||||||
else 이미지 생성 실패 (상태: FAILED)
|
else Job 실패 (status: FAILED)
|
||||||
EventSvc --> Controller: 실패 응답\n{이벤트ID, 상태: 실패,\n오류메시지}
|
JobSvc --> Controller: JobStatusResponse\n{jobId, status: FAILED, error}
|
||||||
Controller --> Client: 200 OK\n{상태: 실패,\n오류메시지}
|
Controller --> Client: 200 OK\n{status: FAILED, error}
|
||||||
end
|
end
|
||||||
|
|
||||||
else 이벤트 미존재
|
else 캐시 미스
|
||||||
EventDB --> EventRepo: null
|
Cache --> JobSvc: null
|
||||||
deactivate EventDB
|
JobSvc --> Controller: NotFoundError
|
||||||
EventRepo --> EventSvc: null
|
Controller --> Client: 404 Not Found\n{error: "Job not found"}
|
||||||
EventSvc --> Controller: 미발견 오류
|
|
||||||
Controller --> Client: 404 Not Found\n{오류: "이벤트를 찾을 수 없음"}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
deactivate EventRepo
|
deactivate Cache
|
||||||
deactivate EventSvc
|
deactivate JobSvc
|
||||||
|
|
||||||
note over Controller, EventDB: 최대 30초 동안 폴링\n(3초 간격, 최대 10회)\n\n타임아웃 시 클라이언트는\n에러 메시지 표시 및\n"다시 생성" 옵션 제공
|
note over Controller, Cache: 최대 30초 동안 폴링\n(3초 간격, 최대 10회)\n\n이미지 URL은 Redis에서 조회\n(TTL: 7일)\n\n타임아웃 시 클라이언트는\n에러 메시지 표시 및\n"다시 생성" 옵션 제공
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
|
|||||||
@ -1,70 +0,0 @@
|
|||||||
@startuml event-콘텐츠생성완료구독
|
|
||||||
!theme mono
|
|
||||||
|
|
||||||
title Event Service - 콘텐츠 생성 완료 이벤트 구독 (Kafka Consumer)
|
|
||||||
|
|
||||||
participant "Kafka\nevent-topic\nConsumer" as Consumer
|
|
||||||
participant "EventHandler" as Handler
|
|
||||||
participant "EventRepository" as Repo
|
|
||||||
database "Event DB" as DB
|
|
||||||
participant "Redis Cache" as Cache
|
|
||||||
|
|
||||||
note over Consumer: Kafka 구독\nevent-topic\n이벤트 타입: ContentCreated
|
|
||||||
|
|
||||||
== ContentCreated 이벤트 수신 ==
|
|
||||||
Consumer -> Handler: ContentCreated 이벤트 수신\n{jobId, eventDraftId, imageUrls}
|
|
||||||
activate Handler
|
|
||||||
|
|
||||||
Handler -> Handler: 이벤트 검증\n- eventDraftId 유효성\n- imageUrls 존재 여부
|
|
||||||
note right: 3가지 스타일 확인\n(simple, fancy, trendy)
|
|
||||||
|
|
||||||
== Event DB에 이미지 URL 저장 ==
|
|
||||||
Handler -> Repo: updateContentImages(eventDraftId, imageUrls)
|
|
||||||
activate Repo
|
|
||||||
|
|
||||||
Repo -> DB: 이벤트 초안 업데이트\nUPDATE event_drafts\nSET content_images = ?,\n updated_at = NOW()\nWHERE event_draft_id = ?
|
|
||||||
activate DB
|
|
||||||
|
|
||||||
note over DB
|
|
||||||
저장 데이터:
|
|
||||||
{
|
|
||||||
"simple": "https://cdn.../simple.png",
|
|
||||||
"fancy": "https://cdn.../fancy.png",
|
|
||||||
"trendy": "https://cdn.../trendy.png"
|
|
||||||
}
|
|
||||||
end note
|
|
||||||
|
|
||||||
DB --> Repo: 업데이트 완료
|
|
||||||
deactivate DB
|
|
||||||
|
|
||||||
Repo --> Handler: 저장 완료
|
|
||||||
deactivate Repo
|
|
||||||
|
|
||||||
== 캐시 무효화 ==
|
|
||||||
Handler -> Cache: 이벤트 초안 캐시 무효화\nDEL event:draft:{eventDraftId}
|
|
||||||
activate Cache
|
|
||||||
Cache --> Handler: 삭제 완료
|
|
||||||
deactivate Cache
|
|
||||||
|
|
||||||
note over Handler: 캐시 무효화로\n다음 조회 시 최신 데이터 반영
|
|
||||||
|
|
||||||
Handler --> Consumer: 처리 완료
|
|
||||||
deactivate Handler
|
|
||||||
|
|
||||||
note over Consumer, DB
|
|
||||||
**처리 전략**
|
|
||||||
- At-Least-Once 전달 보장
|
|
||||||
- 멱등성 처리 (중복 이벤트 무시)
|
|
||||||
- 실패 시 자동 재시도 (최대 3회)
|
|
||||||
- Dead Letter Queue로 실패 이벤트 이동
|
|
||||||
|
|
||||||
**저장 위치**
|
|
||||||
- Event DB: 영구 저장 (이벤트 초안 테이블)
|
|
||||||
- Redis Cache: 임시 저장 (7일 TTL)
|
|
||||||
|
|
||||||
**데이터 정합성**
|
|
||||||
- DB 저장 후 캐시 무효화
|
|
||||||
- 다음 조회 시 DB에서 최신 데이터 로드
|
|
||||||
end note
|
|
||||||
|
|
||||||
@enduml
|
|
||||||
Loading…
x
Reference in New Issue
Block a user