Documents the message delivery and sync distribution layer in Teamgram Server, covering Kafka Inbox-T/Sync-T topics, inbox/outbox model, and the complete message send flow.
Teamgram 的消息投递使用 Kafka 做异步解耦,分为两个主要 topic:
teamgramd/etc/msg.yaml 要点:
yaml
InboxConsumer:
Topics:
- Inbox-T
Brokers:
- 127.0.0.1:9092
Group: Inbox-MainCommunity-S
InboxClient:
Topic: Inbox-T
SyncClient:
Topic: Sync-T
text
Client
-> TL: messages.sendMessage / messages.sendMedia / ...
-> gnetway -> session -> bff.messages
-> bff.messages
-> biz_service (dialog/message/chat/user)
-> msg service (异步投递 + Kafka)
-> messenger.msg produces to Kafka Inbox-T
-> inbox consumes Inbox-T, writes inbox/outbox state
-> produces updates to Kafka Sync-T
-> sync consumes Sync-T, decides UpdatesMe/NotMe/PushRpcResult
-> sync calls session (gRPC) to push updates/rpc_result
-> session routes to correct sessionId
-> gnetway encrypt -> client
inbox 服务通过 Kafka ConsumerGroup 收到消息后,根据 protobuf messageName 分发到对应 core 方法(threading.RunSafe)。
典型模式:
go
case proto.MessageName((*inbox.TLInboxSendUserMessageToInboxV2)(nil)):
threading.RunSafe(func() {
c := core.New(ctx, svcCtx)
r := new(inbox.TLInboxSendUserMessageToInboxV2)
json.Unmarshal(value, r)
c.InboxSendUserMessageToInboxV2(r)
})
inbox 的核心职责:
msg 子服务的 gRPC service impl 文件会保留 TL 签名注释,例如:
这就是跨服务调用时请求/响应的格式契约。
sync 服务消费 Kafka Sync-T,按 protobuf message name 分发到:
最终通过 gRPC 调用 session 把 updates/rpc_result 推回在线会话。
典型模式:
go
case proto.MessageName((*sync.TLSyncPushRpcResult)(nil)):
threading.RunSafe(func() {
c := core.New(ctx, svcCtx)
r := new(sync.TLSyncPushRpcResult)
json.Unmarshal(value, r)
c.SyncPushRpcResult(r)
})
| Topic | 生产者 | 消费者 | 内容 |
|---|---|---|---|
| Inbox-T | messenger.msg | inbox helper | 消息投递(发送/编辑/删除) |
| Sync-T |
Teamgram 使用 inbox/outbox 双写模型:
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 teamgram-messaging-sync-1776079509 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 teamgram-messaging-sync-1776079509 技能
skillhub install teamgram-messaging-sync-1776079509
文件大小: 2.85 KB | 发布时间: 2026-4-15 14:37