refactor: joinResults.result() takes a plain report.Nodes map

This commit is contained in:
Bryan Boreham
2019-10-23 18:39:51 +00:00
parent ad9f8b6f1f
commit 57911118c8
5 changed files with 8 additions and 9 deletions

View File

@@ -31,10 +31,9 @@ func MapEndpoints(endpointToID endpointToIDFunc, topology string) Renderer {
func (e mapEndpoints) Render(ctx context.Context, rpt report.Report) Nodes {
local := LocalNetworks(rpt)
endpoints := SelectEndpoint.Render(ctx, rpt)
ret := newJoinResults(TopologySelector(e.topology).Render(ctx, rpt).Nodes)
for _, n := range endpoints.Nodes {
for _, n := range rpt.Endpoint.Nodes {
// Nodes without a hostid are mapped to pseudo nodes, if
// possible.
if _, ok := n.Latest.Lookup(report.HostNodeID); !ok {
@@ -47,5 +46,5 @@ func (e mapEndpoints) Render(ctx context.Context, rpt report.Report) Nodes {
ret.addChild(n, id, e.topology)
}
}
return ret.result(endpoints)
return ret.result(rpt.Endpoint.Nodes)
}

View File

@@ -47,7 +47,7 @@ func nodes2Hosts(nodes Nodes) Nodes {
}
}
}
return ret.result(nodes)
return ret.result(nodes.Nodes)
}
func endpoint2Host(endpoint report.Node) string {

View File

@@ -197,5 +197,5 @@ func (m Map2Parent) Render(ctx context.Context, rpt report.Report) Nodes {
ret.addChildAndChildren(n, id, Pseudo)
}
}
return ret.result(input)
return ret.result(input.Nodes)
}

View File

@@ -105,5 +105,5 @@ func processes2Names(processes Nodes) Nodes {
ret.addChildAndChildren(n, name, processNameTopology)
}
}
return ret.result(processes)
return ret.result(processes.Nodes)
}

View File

@@ -127,7 +127,7 @@ func (m Map) Render(ctx context.Context, rpt report.Report) Nodes {
span.LogFields(otlog.Int("input.nodes", len(input.Nodes)),
otlog.Int("ouput.nodes", len(output.nodes)))
return output.result(input)
return output.result(input.Nodes)
}
// Condition is a predecate over the entire report that can evaluate to true or false.
@@ -227,8 +227,8 @@ func (ret *joinResults) passThrough(n report.Node) {
// Rewrite Adjacency of nodes in ret mapped from original nodes in
// input, and return the result.
func (ret *joinResults) result(input Nodes) Nodes {
for _, n := range input.Nodes {
func (ret *joinResults) result(input report.Nodes) Nodes {
for _, n := range input {
outID, ok := ret.mapped[n.ID]
if !ok {
continue