本文整理汇总了Golang中github.com/pipeviz/pipeviz/types/system.CoreGraph.PredecessorsWith方法的典型用法代码示例。如果您正苦于以下问题:Golang CoreGraph.PredecessorsWith方法的具体用法?Golang CoreGraph.PredecessorsWith怎么用?Golang CoreGraph.PredecessorsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pipeviz/pipeviz/types/system.CoreGraph
的用法示例。
在下文中一共展示了CoreGraph.PredecessorsWith方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Resolve
func (spec specUnixDomainListener) Resolve(g system.CoreGraph, mid uint64, src system.VertexTuple) (e system.StdEdge, success bool) {
// check for existing edge; this one is quite straightforward
re := g.OutWith(src.ID, q.Qbe(system.EType("listening"), "type", "unix", "path", spec.Path))
if len(re) == 1 {
return re[0], true
}
e = system.StdEdge{
Source: src.ID,
Props: ps.NewMap(),
EType: "listening",
}
e.Props = e.Props.Set("path", system.Property{MsgSrc: mid, Value: spec.Path})
envid, _, hasenv := findEnv(g, src)
if hasenv {
rv := g.PredecessorsWith(envid, q.Qbv(system.VType("comm"), "type", "unix", "path", spec.Path))
if len(rv) == 1 {
success = true
e.Target = rv[0].ID
}
}
return
}
示例2: findDataset
func findDataset(g system.CoreGraph, envid uint64, name []string) (id uint64, success bool) {
// first time through use the parent type
vtype := system.VType("parent-dataset")
id = envid
var n string
for len(name) > 0 {
n, name = name[0], name[1:]
rv := g.PredecessorsWith(id, q.Qbv(vtype, "name", n))
vtype = "dataset"
if len(rv) != 1 {
return 0, false
}
id = rv[0].ID
}
return id, true
}
示例3: Resolve
func (spec DataLink) Resolve(g system.CoreGraph, mid uint64, src system.VertexTuple) (e system.StdEdge, success bool) {
e = system.StdEdge{
Source: src.ID,
Props: ps.NewMap(),
EType: "datalink",
}
// DataLinks have a 'name' field that is expected to be unique for the source, if present
if spec.Name != "" {
// TODO 'name' is a traditional unique key; a change in it inherently denotes a new edge. how to handle this?
// FIXME this approach just always updates the mid, which is weird?
e.Props = e.Props.Set("name", system.Property{MsgSrc: mid, Value: spec.Name})
re := g.OutWith(src.ID, q.Qbe(system.EType("datalink"), "name", spec.Name))
if len(re) == 1 {
success = true
e = re[0]
}
}
if spec.Type != "" {
e.Props = e.Props.Set("type", system.Property{MsgSrc: mid, Value: spec.Type})
}
if spec.Subset != "" {
e.Props = e.Props.Set("subset", system.Property{MsgSrc: mid, Value: spec.Subset})
}
if spec.Interaction != "" {
e.Props = e.Props.Set("interaction", system.Property{MsgSrc: mid, Value: spec.Interaction})
}
// Special bits: if we have ConnUnix data, eliminate ConnNet data, and vice-versa.
var isLocal bool
if spec.ConnUnix.Path != "" {
isLocal = true
e.Props = e.Props.Set("path", system.Property{MsgSrc: mid, Value: spec.ConnUnix.Path})
e.Props = e.Props.Delete("hostname")
e.Props = e.Props.Delete("ipv4")
e.Props = e.Props.Delete("ipv6")
e.Props = e.Props.Delete("port")
e.Props = e.Props.Delete("proto")
} else {
e.Props = e.Props.Set("port", system.Property{MsgSrc: mid, Value: spec.ConnNet.Port})
e.Props = e.Props.Set("proto", system.Property{MsgSrc: mid, Value: spec.ConnNet.Proto})
// can only be one of hostname, ipv4 or ipv6
if spec.ConnNet.Hostname != "" {
e.Props = e.Props.Set("hostname", system.Property{MsgSrc: mid, Value: spec.ConnNet.Hostname})
} else if spec.ConnNet.Ipv4 != "" {
e.Props = e.Props.Set("ipv4", system.Property{MsgSrc: mid, Value: spec.ConnNet.Ipv4})
} else {
e.Props = e.Props.Set("ipv6", system.Property{MsgSrc: mid, Value: spec.ConnNet.Ipv6})
}
}
if success {
return
}
var sock system.VertexTuple
var rv system.VertexTupleVector // just for reuse
// If net, must scan; if local, a bit easier.
if !isLocal {
// First, find the environment vertex
rv = g.VerticesWith(q.Qbv(system.VType("environment")))
var envid uint64
for _, vt := range rv {
if maputil.AnyMatch(e.Props, vt.Vertex.Properties, "hostname", "ipv4", "ipv6") {
envid = vt.ID
break
}
}
// No matching env found, bail out
if envid == 0 {
return
}
// Now, walk the environment's edges to find the vertex representing the port
rv = g.PredecessorsWith(envid, q.Qbv(system.VType("comm"), "type", "port", "port", spec.ConnNet.Port).And(q.Qbe(system.EType("envlink"))))
if len(rv) != 1 {
return
}
sock = rv[0]
// With sock in hand, now find its proc
rv = g.PredecessorsWith(sock.ID, q.Qbe(system.EType("listening"), "proto", spec.ConnNet.Proto).And(q.Qbv(system.VType("process"))))
if len(rv) != 1 {
// TODO could/will we ever allow >1?
return
}
} else {
envid, _, exists := findEnv(g, src)
if !exists {
// this is would be a pretty weird case
return
}
// Walk the graph to find the vertex representing the unix socket
//.........这里部分代码省略.........