MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / callStreamAdapter

Function callStreamAdapter

internal/nodehub/register.go:18–28  ·  view source on GitHub ↗

callStreamAdapter 把 nodes.HubStreamFunc 适配到 *Hub.CallStream。 hub any 必须是 *Hub 类型;其他类型将返回错误。

(ctx context.Context, hub any, nodeID, method string, body any)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

convertFramesFunction · 0.85
CallStreamMethod · 0.80

Tested by

no test coverage detected