mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
Split addToResults into multiple functions
This commit is contained in:
committed by
Matthias Radestock
parent
fa03a0be08
commit
3ebd215b6a
@@ -158,20 +158,42 @@ func newJoinResults() joinResults {
|
||||
return joinResults{nodes: make(report.Nodes), mapped: map[string]string{}}
|
||||
}
|
||||
|
||||
// Add Node M under id, creating a new result node if not already there
|
||||
// incrementing a counter if nonblank, and updating the mapping from old ID to new ID
|
||||
func (ret *joinResults) addToResults(m report.Node, id string, addChildren bool, create func(string) report.Node, counters ...string) {
|
||||
// Add Endpoint Node m under id, creating a new result node if not already there
|
||||
// and updating the mapping from old ID to new ID
|
||||
// Note we do not update any counters for child topologies here because we never look at endpoint counts
|
||||
func (ret *joinResults) addEndpointChild(m report.Node, id string, create func(string) report.Node) {
|
||||
result, exists := ret.nodes[id]
|
||||
if !exists {
|
||||
result = create(id)
|
||||
}
|
||||
result.Children = result.Children.Add(m)
|
||||
if addChildren {
|
||||
result.Children = result.Children.Merge(m.Children)
|
||||
ret.nodes[id] = result
|
||||
ret.mapped[m.ID] = id
|
||||
}
|
||||
|
||||
// Add Node m as a child of the node at id, creating a new result node if not already there
|
||||
// incrementing a count of the topology, and updating the mapping from old ID to new ID
|
||||
func (ret *joinResults) addChild(m report.Node, id string, create func(string) report.Node) {
|
||||
result, exists := ret.nodes[id]
|
||||
if !exists {
|
||||
result = create(id)
|
||||
}
|
||||
for _, c := range counters {
|
||||
result.Counters = result.Counters.Add(c, 1)
|
||||
result.Children = result.Children.Add(m)
|
||||
result.Counters = result.Counters.Add(m.Topology, 1)
|
||||
ret.nodes[id] = result
|
||||
ret.mapped[m.ID] = id
|
||||
}
|
||||
|
||||
// Add m and its children as children under id, creating a new result node if not already there,
|
||||
// incrementing a count of the topology, and updating the mapping from old ID to new ID
|
||||
func (ret *joinResults) addChildAndChildren(m report.Node, id string, create func(string) report.Node) {
|
||||
result, exists := ret.nodes[id]
|
||||
if !exists {
|
||||
result = create(id)
|
||||
}
|
||||
result.Children = result.Children.Add(m)
|
||||
result.Children = result.Children.Merge(m.Children)
|
||||
result.Counters = result.Counters.Add(m.Topology, 1)
|
||||
ret.nodes[id] = result
|
||||
ret.mapped[m.ID] = id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user