callStreamAdapter 把 nodes.HubStreamFunc 适配到 *Hub.CallStream。 hub any 必须是 *Hub 类型;其他类型将返回错误。
(ctx context.Context, hub any, nodeID, method string, body any)
| 16 | // callStreamAdapter 把 nodes.HubStreamFunc 适配到 *Hub.CallStream。 |
| 17 | // hub any 必须是 *Hub 类型;其他类型将返回错误。 |
| 18 | func callStreamAdapter(ctx context.Context, hub any, nodeID, method string, body any) (nodes.HubStream, error) { |
| 19 | h, ok := hub.(*Hub) |
| 20 | if !ok { |
| 21 | return nil, ErrNodeOffline |
| 22 | } |
| 23 | s, err := h.CallStream(ctx, nodeID, method, body) |
| 24 | if err != nil { |
| 25 | return nil, err |
| 26 | } |
| 27 | return &nodesStreamAdapter{s: s, frames: convertFrames(s)}, nil |
| 28 | } |
| 29 | |
| 30 | // nodesStreamAdapter 把 *Stream 包成 nodes.HubStream(重新打包 frames 通道 |
| 31 | // 以适配 nodes 包定义的 HubStreamFrame 类型)。 |
nothing calls this directly
no test coverage detected