veyron/lib/stats: Let Glob return inner nodes
With this change, Glob will include inner nodes that don't have a value
when includeValues is false. This means that Glob can be used to
traverse the tree one level at a time. WatchGlob will return all nodes
on the first cycle, and then only the nodes that change afterwards.
Change-Id: I221b4f4672992b3173810c7e6a4b63985eaba1b1
diff --git a/lib/stats/glob.go b/lib/stats/glob.go
index 2ba7cb7..c630e1e 100644
--- a/lib/stats/glob.go
+++ b/lib/stats/glob.go
@@ -37,12 +37,14 @@
// globStepLocked applies a glob recursively.
func globStepLocked(prefix string, g *glob.Glob, n *node, updatedSince time.Time, includeValues bool, result *[]KeyValue) {
- if g.Len() == 0 && n.object != nil && (updatedSince.IsZero() || !n.object.LastUpdate().Before(updatedSince)) {
- var v interface{}
- if includeValues {
- v = n.object.Value()
+ if g.Len() == 0 {
+ if updatedSince.IsZero() || (n.object != nil && !n.object.LastUpdate().Before(updatedSince)) {
+ var v interface{}
+ if includeValues && n.object != nil {
+ v = n.object.Value()
+ }
+ *result = append(*result, KeyValue{prefix, v})
}
- *result = append(*result, KeyValue{prefix, v})
}
if g.Finished() {
return