mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 17:51:21 +00:00
refactor: simplify joinResults.add*
After dropping extra metadata in the rest of this PR, our usage of joinResults.add* only ever ends creating minimal nodes, from just an id and topology. Hence joinResults.add* can be invoked with simply an id and topology instead of a generic node creation function.
This commit is contained in:
@@ -76,10 +76,6 @@ var ProcessNameRenderer = CustomRenderer{RenderFunc: processes2Names, Renderer:
|
||||
type endpoints2Processes struct {
|
||||
}
|
||||
|
||||
func newProcessNode(id string) report.Node {
|
||||
return report.MakeNode(id).WithTopology(report.Process)
|
||||
}
|
||||
|
||||
func (e endpoints2Processes) Render(rpt report.Report) Nodes {
|
||||
if len(rpt.Process.Nodes) == 0 {
|
||||
return Nodes{}
|
||||
@@ -93,7 +89,7 @@ func (e endpoints2Processes) Render(rpt report.Report) Nodes {
|
||||
// Nodes without a hostid are treated as pseudo nodes
|
||||
if hostNodeID, ok := n.Latest.Lookup(report.HostNodeID); !ok {
|
||||
if id, ok := pseudoNodeID(n, local); ok {
|
||||
ret.addChild(n, id, newPseudoNode)
|
||||
ret.addChild(n, id, Pseudo)
|
||||
}
|
||||
} else {
|
||||
pid, ok := n.Latest.Lookup(process.PID)
|
||||
@@ -106,7 +102,7 @@ func (e endpoints2Processes) Render(rpt report.Report) Nodes {
|
||||
|
||||
hostID, _ := report.ParseHostNodeID(hostNodeID)
|
||||
id := report.MakeProcessNodeID(hostID, pid)
|
||||
ret.addChild(n, id, newProcessNode)
|
||||
ret.addChild(n, id, report.Process)
|
||||
}
|
||||
}
|
||||
return ret.result(endpoints)
|
||||
@@ -141,10 +137,6 @@ func hasMoreThanOneConnection(n report.Node, endpoints report.Nodes) bool {
|
||||
|
||||
var processNameTopology = MakeGroupNodeTopology(report.Process, process.Name)
|
||||
|
||||
func newProcessNameNode(id string) report.Node {
|
||||
return report.MakeNode(id).WithTopology(processNameTopology)
|
||||
}
|
||||
|
||||
// processes2Names maps process Nodes to Nodes for each process name.
|
||||
func processes2Names(processes Nodes) Nodes {
|
||||
ret := newJoinResults(nil)
|
||||
@@ -153,7 +145,7 @@ func processes2Names(processes Nodes) Nodes {
|
||||
if n.Topology == Pseudo {
|
||||
ret.passThrough(n)
|
||||
} else if name, ok := n.Latest.Lookup(process.Name); ok {
|
||||
ret.addChildAndChildren(n, name, newProcessNameNode)
|
||||
ret.addChildAndChildren(n, name, processNameTopology)
|
||||
}
|
||||
}
|
||||
return ret.result(processes)
|
||||
|
||||
Reference in New Issue
Block a user