command
Version:
v0.9.1
Opens a new window with list of versions in this module.
Published: Aug 21, 2026
License: Apache-2.0
Opens a new window with license information.
Imports: 8
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
router —— HTTP 消息路由
演示 pkg/transport/router 按 presence ID 定点投递、按 stream 群发,以及 QueueDeferred 攒批 flush。
运行
go run ./examples/router
curl "http://localhost:8284/join?session=s1&user=alice&channel=room1"
curl "http://localhost:8284/say?channel=room1&msg=hello"
curl "http://localhost:8284/send?session=s1&msg=hi"
curl http://localhost:8284/batch
说明
- 配合
pkg/transport/presence 追踪「谁在哪个频道」;sinkRegistry 模拟 WebSocket 的本地投递函数。
SendToStream 群发给频道所有成员;SendToPresenceIDs 按 session 定点(可带 Node 跨节点转发)。
QueueDeferred + FlushDeferred 把多条消息合并一次投递,降低 IO 开销。
Documentation
¶
router 示例:多语义消息路由 + 攒批。
演示 pkg/router:按 presence ID 定点投递、按 stream 群发、QueueDeferred 攒批。
配合 pkg/presence 查询频道成员,实现"发消息给某频道所有人"。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.