router

command
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

Overview

router 示例:多语义消息路由 + 攒批。

演示 pkg/router:按 presence ID 定点投递、按 stream 群发、QueueDeferred 攒批。 配合 pkg/presence 查询频道成员,实现"发消息给某频道所有人"。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL