Skip to content

feat: 실시간 알림(Realtime) 및 AI 메시징 인프라 구축#6

Merged
i3months merged 36 commits into
devfrom
feature/realtime-ai-bootstrap
May 13, 2026
Merged

feat: 실시간 알림(Realtime) 및 AI 메시징 인프라 구축#6
i3months merged 36 commits into
devfrom
feature/realtime-ai-bootstrap

Conversation

@csh1668

@csh1668 csh1668 commented May 8, 2026

Copy link
Copy Markdown
Contributor

주요 작업 내용

이번 PR은 실시간 알림 시스템과 AI 메시지 처리 인프라를 구축하는 기초 작업(Bootstrap)을 포함하고 있습니다. AI 서버에서 발생한 이벤트를 RabbitMQ를 거쳐 Realtime 서버가 SSE(Server-Sent Events)를 통해 클라이언트에게 전달하는 전체 파이프라인을 구성했습니다.

  1. Realtime 서버 (Go)
  • SSE 전송 계층: Chi 라우터 기반의 SSE 서버를 구현하여 클라이언트와 실시간 연결을 관리합니다.
  • 세션 레지스트리: 활성화된 클라이언트 연결을 추적하고 관리하는 SessionRegistry를 도입했습니다.
  • 메시지 디스패처: RabbitMQ에서 소비(Consume)한 메시지를 올바른 세션으로 라우팅하는 Dispatcher 로직을 구현했습니다.
  • 검증: registry, dispatcher, sse 등 핵심 로직에 대한 단위 테스트를 추가했습니다.
  1. AI 서버 (Python/FastAPI)
  • 메시징 프레임워크: aio-pika를 사용하여 비동기 AMQP Publisher 및 Consumer 구조를 설계했습니다.
  • 모델링: 메시지 규격을 정의하는 Envelope 및 페이로드(analyze 등)를 Pydantic 모델로 표준화했습니다.
  • 멱등성 처리: LRU 캐시를 활용하여 중복 메시지를 방지하는 Idempotency 레이어를 추가했습니다.
  • 부트스트랩 컨슈머: 이력서 분석 등의 요청을 처리할 수 있는 기초 ResumeConsumer를 구현했습니다.
  1. 인프라 및 설정
  • RabbitMQ: stackup.realtime (topic exchange) 및 session.notify 큐 설정을 definitions.json에 정의했습니다.
  • Docker: 두 서비스의 컨테이너화를 위한 Dockerfile 및 docker-compose.yml을 작성했습니다.
  • 문서화: 아키텍처, 환경 변수, 메시징 규격 문서를 최신화하고 각 서비스의 CLAUDE.md 가이드를 추가했습니다.
  1. 검증 결과
  • AI 서버: pytest를 통한 모델 및 컨슈머 로직 검증 완료
  • Realtime 서버: go test를 통한 세션 및 전송 로직 검증 완료
  • 통합: docker-compose를 통한 서비스 간 오케스트레이션 확인

csh1668 and others added 27 commits May 8, 2026 21:24
Implement bridge package with envelope parsing and dispatcher for routing
RabbitMQ messages to session subscribers. All 4 bridge tests pass with race
detector enabled; full realtime suite (15 tests) passes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@csh1668 csh1668 changed the title feature/realtime ai bootstrap feat: Realtime 서버 부트스트랩 작업 May 8, 2026
@csh1668 csh1668 changed the title feat: Realtime 서버 부트스트랩 작업 feat: 실시간 알림(Realtime) 및 AI 메시징 인프라 구축 May 8, 2026
@i3months i3months self-requested a review May 11, 2026 09:51

@Jaeho-Site Jaeho-Site left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go언어 재밌네요. 앞으로 리뷰 야무지게 해보겠습니다.

Comment on lines +47 to +52
ch, err := conn.Channel()
if err != nil {
return err
}
defer ch.Close()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QoS 설정이 안되어있는데, 아직 로컬용이라 그런건지 궁금합니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QoS prefetch is now set (prefetch=1) with contextual error handling; commit c343a57.

Comment on lines +62 to +65

closeCh := conn.NotifyClose(make(chan *amqp.Error, 1))

for {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connection만이 아니라 Channel 닫힘도 처리해주면 좋을 것 같아요.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Channel close notifications are handled alongside connection close to trigger reconnect; commit c343a57.

Comment thread realtime/internal/messaging/consumer.go Outdated
Comment on lines +70 to +71
case err := <-closeCh:
return err

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closeCh nil 반환 시 consumer 무음 종료되는 이슈 확인 부탁드려요

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nil/closed close notifications now normalize to ErrClosed to avoid silent exit and force reconnect; commit c343a57.

@csh1668

csh1668 commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot 이 PR을 리뷰해줘

@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stackup Ready Ready Preview, Comment May 11, 2026 0:00am

Agent-Logs-Url: https://github.com/Team-StackUp/stackup/sessions/f38bbbdd-14f5-46b7-beae-e66a9a7870c7

Co-authored-by: csh1668 <18442452+csh1668@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Team-StackUp/stackup/sessions/f38bbbdd-14f5-46b7-beae-e66a9a7870c7

Co-authored-by: csh1668 <18442452+csh1668@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Team-StackUp/stackup/sessions/f38bbbdd-14f5-46b7-beae-e66a9a7870c7

Co-authored-by: csh1668 <18442452+csh1668@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Team-StackUp/stackup/sessions/f38bbbdd-14f5-46b7-beae-e66a9a7870c7

Co-authored-by: csh1668 <18442452+csh1668@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Team-StackUp/stackup/sessions/f38bbbdd-14f5-46b7-beae-e66a9a7870c7

Co-authored-by: csh1668 <18442452+csh1668@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Team-StackUp/stackup/sessions/f38bbbdd-14f5-46b7-beae-e66a9a7870c7

Co-authored-by: csh1668 <18442452+csh1668@users.noreply.github.com>

Copilot AI commented May 11, 2026

Copy link
Copy Markdown
Contributor

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • releases.astral.sh
    • Triggering command: /home/REDACTED/.local/bin/uv uv sync (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Jaeho-Site Jaeho-Site left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Code

Comment thread ai/src/ai_server/main.py
Comment on lines +16 to +24
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
runtime = MessagingRuntime(settings)
await runtime.start()
app.state.messaging = runtime
try:
yield
finally:
await runtime.stop()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime.start() 실패 시 finally 블록 진입 불가로 runtime.stop()이 호출되지 않고 RabbitMQ 연결이 좀비가 되는 문제가 있을 것 같아요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좀비 connection 막도록 try/finally 진입 순서를 변경해 runtime.start() 실패 시에도 stop() 이 호출되도록 수정했습니다. MessagingRuntime.stop() 은 내부 상태 None 가드가 있어 부분 초기화에서도 안전합니다. 회귀 방지 테스트(ai/tests/test_lifespan.py) 추가. commit 8eda222.

runtime.start()가 부분 초기화(connection open 후 exchange/queue declare 실패) 단계에서 raise하면 finally 블록 진입 불가로 stop()이 호출되지 않아 AMQP connection이 좀비가 되던 문제 수정. MessagingRuntime.stop()은 내부 상태 None 가드가 있어 부분 초기화 상태에서도 안전하다.

PR #6 review (Jaeho-Site) 대응.
@i3months i3months merged commit b623a91 into dev May 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants