veyron2/ipc/model.go: Normalize the Glob interfaces
With this change, the Glob__ and GlobChildren__ methods both take a
ServerContext as first argument and return a channel.
All the Glob() implementations are updated to use the AllGlobber
interface from ipc/model.go. This means that the mounttable.Globbable
interface is no longer needed and can now be removed.
The VGlob interface is renamed to Globber.
Change-Id: Idf1cd4663375eb3f1fc3baf7ca7606f59f7ded19
diff --git a/services/mgmt/stats/impl/stats.go b/services/mgmt/stats/impl/stats.go
index b398ee8..f51b12b 100644
--- a/services/mgmt/stats/impl/stats.go
+++ b/services/mgmt/stats/impl/stats.go
@@ -35,21 +35,22 @@
return stats.StatsServer(&statsService{suffix, watchFreq})
}
-// Glob returns the name of all objects that match pattern.
-func (i *statsService) Glob(ctx ipc.GlobContext, pattern string) error {
- vlog.VI(1).Infof("%v.Glob(%q)", i.suffix, pattern)
+// Glob__ returns the name of all objects that match pattern.
+func (i *statsService) Glob__(ctx ipc.ServerContext, pattern string) (<-chan naming.VDLMountEntry, error) {
+ vlog.VI(1).Infof("%v.Glob__(%q)", i.suffix, pattern)
- it := libstats.Glob(i.suffix, pattern, time.Time{}, false)
- for it.Advance() {
- ctx.SendStream().Send(naming.VDLMountEntry{Name: it.Value().Key})
- }
- if err := it.Err(); err != nil {
- if err == libstats.ErrNotFound {
- return errNotFound
+ ch := make(chan naming.VDLMountEntry)
+ go func() {
+ defer close(ch)
+ it := libstats.Glob(i.suffix, pattern, time.Time{}, false)
+ for it.Advance() {
+ ch <- naming.VDLMountEntry{Name: it.Value().Key}
}
- return errOperationFailed
- }
- return nil
+ if err := it.Err(); err != nil {
+ vlog.VI(1).Infof("libstats.Glob(%q, %q) failed: %v", i.suffix, pattern, err)
+ }
+ }()
+ return ch, nil
}
// WatchGlob returns the name and value of the objects that match the request,