本文整理匯總了Golang中github.com/redhat-cip/skydive/topology/graph.Graph.LookupFirstNode方法的典型用法代碼示例。如果您正苦於以下問題:Golang Graph.LookupFirstNode方法的具體用法?Golang Graph.LookupFirstNode怎麽用?Golang Graph.LookupFirstNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/redhat-cip/skydive/topology/graph.Graph
的用法示例。
在下文中一共展示了Graph.LookupFirstNode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: testCleanup
func testCleanup(t *testing.T, g *graph.Graph, cmds []string, ints []string) {
// cleanup side on the test
testPassed := false
onChange := func(ws *websocket.Conn) {
g.Lock()
defer g.Unlock()
if !testPassed {
clean := true
for _, intf := range ints {
n := g.LookupFirstNode(graph.Metadatas{"Name": intf})
if n != nil {
clean = false
break
}
}
if clean {
testPassed = true
ws.Close()
}
}
}
testTopology(t, g, cmds, onChange)
if !testPassed {
t.Error("test not executed or failed")
}
}
示例2: LookupNodeFromNodePathString
func LookupNodeFromNodePathString(g *graph.Graph, s string) *graph.Node {
parts := strings.Split(s, "/")
m, err := nodePathPartToMetadata(parts[0])
if err != nil {
logging.GetLogger().Errorf("Unable to parse a part of node path string (%s): %s", parts[0], err.Error())
return nil
}
node := g.LookupFirstNode(m)
if node == nil {
return nil
}
for _, part := range parts[1:] {
m, err := nodePathPartToMetadata(part)
if err != nil {
return nil
}
node = g.LookupFirstChild(node, m)
if node == nil {
return nil
}
}
return node
}