Files
appks/docs/adr/003-nats-for-messaging.md
zhenyi 1000f8a80d chore(infra): add gRPC layer, update protobufs, remove immediate module
- Add gRPC service modules: auth, channel, channel settings, member,
  permission
- Update protobuf definitions and generated code
- Remove immediate/ real-time module (superseded by IM service)
- Update etcd discovery and registration
- Update cache, error, config, and build infrastructure
- Add ADR documentation
- Update OpenAPI spec
2026-06-10 18:49:42 +08:00

1.2 KiB

ADR-003: 使用 NATS JetStream 作为消息队列 / NATS JetStream for Messaging

状态 / Status

Accepted

日期 / Date: 2024-01-01

背景 / Context

平台的实时 IM 系统需要可靠的消息传递机制,支持发布/订阅模式和消息持久化。

The platform's real-time IM system needs reliable messaging with pub/sub patterns and message persistence.

决策 / Decision

使用 NATS JetStream 作为消息队列。

Use NATS JetStream as the message queue.

考虑的方案 / Considered Options

  1. NATS JetStream — 轻量级、高性能
  2. Apache Kafka — 高吞吐但运维复杂
  3. RabbitMQ — 功能丰富但性能较低

后果 / Consequences

正面 / Positive

  • 轻量级部署 / Lightweight deployment
  • 高性能消息传递 / High-performance messaging
  • 内置持久化 / Built-in persistence
  • 良好的 Rust 客户端支持 / Good Rust client support

负面 / Negative

  • 生态系统不如 Kafka 成熟 / Ecosystem less mature than Kafka
  • 监控工具有限 / Limited monitoring tools

实现细节 / Implementation Details

  • Publisher: 发布事件到 JetStream
  • Subscriber: 订阅并处理事件
  • Stream prefix: 可配置的流前缀