Repository navigation
feat(upload): implement concurrent async upload pipeline with WebSock… - #334
Conversation
…ets and Resilience4j - Refactored synchronous, sequential document uploads to a concurrent, non-blocking pipeline using CompletableFuture and Spring @async. - Integrated STOMP WebSockets with Redis-backed, one-time ticket authentication for real-time progress updates. - Added Resilience4j circuit breakers, retries, and bulkhead policies to S3 upload and OCR provider integrations (Google Vision, Tesseract). - Configured immediate file-by-file Kafka message publishing to start OCR processing as soon as individual files land in storage. - Added a dedicated thread-pool executor for the upload pipeline and Actuator metrics for circuit breakers. Signed-off-by: aniebietafia <aniebietafia87@gmail.com>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (22)
📝 WalkthroughWalkthroughIntroduces an async streaming upload pipeline that returns HTTP 202 immediately and pushes real-time extraction progress over STOMP/WebSocket. Adds ticket-based WebSocket authentication via Redis, configures Resilience4j circuit breakers, retries, and bulkheads for S3 and OCR providers, and wires progress notifications into both the upload pipeline and Kafka OCR message listener. ChangesAsync Streaming Upload Pipeline with WebSocket Progress and Resilience4j
Sequence DiagramsequenceDiagram
participant Client
participant WebSocketTicketController
participant WebSocketTicketService
participant Redis
participant DocumentController
participant StreamingUploadPipeline
participant ExtractionProgressService
participant OcrMessageListener
rect rgba(70, 130, 180, 0.5)
note over Client,Redis: Ticket issuance
Client->>WebSocketTicketController: POST /api/v1/ws/ticket
WebSocketTicketController->>WebSocketTicketService: issueTicket(userId)
WebSocketTicketService->>Redis: SET ws:ticket:{uuid} EX 30
WebSocketTicketController-->>Client: {ticket, wsUrl}
end
rect rgba(60, 179, 113, 0.5)
note over Client,StreamingUploadPipeline: Async upload
Client->>DocumentController: POST /upload (files)
DocumentController->>StreamingUploadPipeline: processUploadAsync(files, collectionId, autoExtract=false)
DocumentController-->>Client: 202 {collectionId, wsSubscriptionTopic}
StreamingUploadPipeline->>ExtractionProgressService: sendUploadStarted
loop each file
StreamingUploadPipeline->>ExtractionProgressService: sendFileUploaded / sendFileUploadFailed
end
StreamingUploadPipeline->>ExtractionProgressService: sendPipelineCompleted
end
rect rgba(210, 105, 30, 0.5)
note over OcrMessageListener,ExtractionProgressService: OCR extraction progress
OcrMessageListener->>ExtractionProgressService: sendExtractionCompleted / sendExtractionFailed
ExtractionProgressService-->>Client: STOMP /user/queue/extraction-progress
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
|
|
…ets and Resilience4j
Summary by CodeRabbit
New Features
Bug Fixes