MultiPushHandler 是一个把 PushHandler 各事件分发到多个独立闭包的复合实现。 nodehub 的 PushHandler 是单一接口,但实际有多个业务模块需要消费不同事件 (self-sync 关心 OnHello、SSE bridge 关心 OnLog/OnTracerouteHop、usage 接收器关心 OnUsagePush)。MultiPushHandler 提供一个零依赖的扇出装配点: hub := nodehub.New(nodehub.Options{ PushHandler: &nodehub.MultiPushHandler{
| 17 | // |
| 18 | // 任意字段为 nil 时该事件 no-op(OnUsagePush 返回 nil 触发 ack)。 |
| 19 | type MultiPushHandler struct { |
| 20 | HelloHandler func(nodeID string, body []byte) |
| 21 | UsagePushHandler func(nodeID string, seq uint64, body []byte) error |
| 22 | LogHandler func(nodeID, reqID string, body []byte) |
| 23 | TracerouteHopHandler func(nodeID, reqID string, body []byte) |
| 24 | } |
| 25 | |
| 26 | var _ PushHandler = (*MultiPushHandler)(nil) |
| 27 |
nothing calls this directly
no outgoing calls
no test coverage detected