K
KRYFT Problem Bank
백엔드 어려움 코딩

간단한 메시지 큐 구현

In-memory 메시지 큐 시스템 구현

40분
95점
#3704

문제 설명

간단한 in-memory 메시지 큐를 구현하세요. Pub/Sub 패턴을 지원해야 합니다.

요구사항

  • 토픽(topic) 생성 및 삭제
  • 메시지 발행(publish)
  • 구독자(subscriber) 등록/해제
  • 메시지 수신(consume) - pull 방식
  • 메시지 확인(ack) 처리
  • 확인되지 않은 메시지 재전송

인터페이스


class MessageQueue:
    def create_topic(topic: str) -> bool
    def delete_topic(topic: str) -> bool
    def publish(topic: str, message: any) -> str  # returns message_id
    def subscribe(topic: str, subscriber_id: str) -> bool
    def unsubscribe(topic: str, subscriber_id: str) -> bool
    def consume(topic: str, subscriber_id: str) -> Message
    def ack(message_id: str, subscriber_id: str) -> bool

평가 기준

  • 메시지 순서 보장
  • 중복 방지
  • 동시성 고려
실행 버튼을 눌러 코드를 실행하세요.