MCPcopy Index your code
hub / github.com/0xUnixIO/pulse / clientFor

Method clientFor

internal/serverapi/api.go:794–809  ·  view source on GitHub ↗
(nodeID string)

Source from the content-addressed store, hash-verified

792}
793
794func (a *API) clientFor(nodeID string) (*nodes.Client, error) {
795 // 命中缓存直接返回(避免重复构造)
796 if v, ok := a.clientCache.Load(nodeID); ok {
797 return v.(*nodes.Client), nil
798 }
799 node, err := a.store.Get(nodeID)
800 if err != nil {
801 return nil, err
802 }
803 if node.Disabled {
804 return nil, fmt.Errorf("node is disabled")
805 }
806 client := a.clientFactory(node)
807 a.clientCache.Store(nodeID, client)
808 return client, nil
809}
810
811func (a *API) evictClient(nodeID string) {
812 a.clientCache.Delete(nodeID)

Callers 15

handleNodeRuntimeMethod · 0.95
handleNodeMetricsMethod · 0.95
handleNodeStatusMethod · 0.95
handleNodeConfigMethod · 0.95
handleNodeLogsMethod · 0.95
handleNodeLogsStreamMethod · 0.95
handleNodeUsageMethod · 0.95
handleNodeStartMethod · 0.95
handleNodeStopMethod · 0.95
handleNodeRestartMethod · 0.95
handleNodeApplyMethod · 0.95
handleNodeSpeedTestMethod · 0.95

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected