Review feedback

This commit is contained in:
Tom Wilkie
2016-04-07 12:23:06 +01:00
parent 22402c34f7
commit 674cb24f2a
3 changed files with 16 additions and 17 deletions

View File

@@ -108,12 +108,12 @@ describe('TopologyUtils', () => {
});
describe('filterHiddenTopologies', () => {
it('should filter out empty topos that set hidden_if_empty=true', () => {
it('should filter out empty topos that set hide_if_empty=true', () => {
const topos = [
{id: 'a', hidden_if_empty: true, stats: {node_count: 0, filtered_nodes:0}},
{id: 'b', hidden_if_empty: true, stats: {node_count: 1, filtered_nodes:0}},
{id: 'c', hidden_if_empty: true, stats: {node_count: 0, filtered_nodes:1}},
{id: 'd', hidden_if_empty: false, stats: {node_count: 0, filtered_nodes:0}}
{id: 'a', hide_if_empty: true, stats: {node_count: 0, filtered_nodes:0}},
{id: 'b', hide_if_empty: true, stats: {node_count: 1, filtered_nodes:0}},
{id: 'c', hide_if_empty: true, stats: {node_count: 0, filtered_nodes:1}},
{id: 'd', hide_if_empty: false, stats: {node_count: 0, filtered_nodes:0}}
];
const res = TopologyUtils.filterHiddenTopologies(topos);

View File

@@ -58,25 +58,24 @@ func ColorConnected(r Renderer) Renderer {
// Filter removes nodes from a view based on a predicate.
type Filter struct {
Renderer
FilterFunc func(report.Node) bool
ReportFiltered bool // false means we don't report stats for how many are filtered
FilterFunc func(report.Node) bool
Silent bool // true means we don't report stats for how many are filtered
}
// MakeFilter makes a new Filter.
func MakeFilter(f func(report.Node) bool, r Renderer) Renderer {
return Memoise(&Filter{
Renderer: r,
FilterFunc: f,
ReportFiltered: true,
Renderer: r,
FilterFunc: f,
})
}
// MakeSilentFilter makes a new Filter which does not report how many nodes it filters in Stats.
func MakeSilentFilter(f func(report.Node) bool, r Renderer) Renderer {
return Memoise(&Filter{
Renderer: r,
FilterFunc: f,
ReportFiltered: false,
Renderer: r,
FilterFunc: f,
Silent: true,
})
}
@@ -130,7 +129,7 @@ func (f *Filter) render(rpt report.Report) (report.Nodes, int) {
// Stats implements Renderer
func (f Filter) Stats(rpt report.Report) Stats {
var upstream = f.Renderer.Stats(rpt)
if f.ReportFiltered {
if !f.Silent {
_, filtered := f.render(rpt)
upstream.FilteredNodes += filtered
}

View File

@@ -228,10 +228,10 @@ var PodRenderer = MakeReduce(
_, isConnected := n.Latest.Lookup(IsConnected)
return n.Topology != Pseudo || isConnected
},
MakeMap(
ColorConnected(MakeMap(
MapContainer2Pod,
ColorConnected(ContainerRenderer),
),
ContainerRenderer,
)),
),
SelectPod,
)