Merge "veyron/runtimes/google/namespace: Namespace should not take a runtime parameter on New."
diff --git a/runtimes/google/naming/namespace/all_test.go b/runtimes/google/naming/namespace/all_test.go
index 64c1cd2..2bb395c 100644
--- a/runtimes/google/naming/namespace/all_test.go
+++ b/runtimes/google/naming/namespace/all_test.go
@@ -623,13 +623,10 @@
}
func TestBadRoots(t *testing.T) {
- _, r, cleanup := createRuntimes(t)
- defer cleanup()
-
- if _, err := namespace.New(r); err != nil {
+ if _, err := namespace.New(); err != nil {
t.Errorf("namespace.New should not have failed with no roots")
}
- if _, err := namespace.New(r, "not a rooted name"); err == nil {
+ if _, err := namespace.New("not a rooted name"); err == nil {
t.Errorf("namespace.New should have failed with an unrooted name")
}
}
diff --git a/runtimes/google/naming/namespace/cache_test.go b/runtimes/google/naming/namespace/cache_test.go
index e12cd69..1b7894e 100644
--- a/runtimes/google/naming/namespace/cache_test.go
+++ b/runtimes/google/naming/namespace/cache_test.go
@@ -109,7 +109,7 @@
{"/h2//c", "/h3"},
{"/h3//d", "/h4:1234"},
}
- ns, _ := New(nil)
+ ns, _ := New()
c := ns.resolutionCache.(*ttlCache)
for _, p := range preload {
e := &naming.MountEntry{Servers: []naming.MountedServer{naming.MountedServer{Server: "p.server", Expires: future(3000)}}}
@@ -152,7 +152,7 @@
}
func TestCacheDisableEnable(t *testing.T) {
- ns, _ := New(nil)
+ ns, _ := New()
// Default should be working resolution cache.
name := "/h1//a"
diff --git a/runtimes/google/naming/namespace/glob.go b/runtimes/google/naming/namespace/glob.go
index 632c0b8..937b6b6 100644
--- a/runtimes/google/naming/namespace/glob.go
+++ b/runtimes/google/naming/namespace/glob.go
@@ -7,6 +7,7 @@
"veyron.io/veyron/veyron/lib/glob"
+ "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/context"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
@@ -30,6 +31,7 @@
// recursive true to continue below the matched pattern
func (ns *namespace) globAtServer(ctx context.T, qe *queuedEntry, pattern *glob.Glob, l *list.List) error {
server := qe.me
+ client := veyron2.RuntimeFromContext(ctx).Client()
pstr := pattern.String()
vlog.VI(2).Infof("globAtServer(%v, %v)", *server, pstr)
@@ -54,7 +56,6 @@
// Don't further resolve s.Server.
callCtx, _ := ctx.WithTimeout(callTimeout)
- client := ns.rt.Client()
call, err := client.StartCall(callCtx, s.Server, ipc.GlobMethod, []interface{}{pstr}, options.NoResolve(true))
if err != nil {
lastErr = err
diff --git a/runtimes/google/naming/namespace/mount.go b/runtimes/google/naming/namespace/mount.go
index ac2e875..3d4e03a 100644
--- a/runtimes/google/naming/namespace/mount.go
+++ b/runtimes/google/naming/namespace/mount.go
@@ -5,6 +5,7 @@
inaming "veyron.io/veyron/veyron/runtimes/google/naming"
+ "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/context"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
@@ -118,9 +119,12 @@
}
}
}
+
+ client := veyron2.RuntimeFromContext(ctx).Client()
+
// Mount the server in all the returned mount tables.
f := func(ctx context.T, mt, id string) status {
- return mountIntoMountTable(ctx, ns.rt.Client(), mt, server, ttl, flags, id)
+ return mountIntoMountTable(ctx, client, mt, server, ttl, flags, id)
}
err := ns.dispatch(ctx, name, f)
vlog.VI(1).Infof("Mount(%s, %s) -> %v", name, server, err)
@@ -130,8 +134,9 @@
func (ns *namespace) Unmount(ctx context.T, name, server string) error {
defer vlog.LogCall()()
// Unmount the server from all the mount tables.
- f := func(ctx context.T, mt, id string) status {
- return unmountFromMountTable(ctx, ns.rt.Client(), mt, server, id)
+ client := veyron2.RuntimeFromContext(ctx).Client()
+ f := func(context context.T, mt, id string) status {
+ return unmountFromMountTable(ctx, client, mt, server, id)
}
err := ns.dispatch(ctx, name, f)
vlog.VI(1).Infof("Unmount(%s, %s) -> %v", name, server, err)
diff --git a/runtimes/google/naming/namespace/namespace.go b/runtimes/google/naming/namespace/namespace.go
index 9d58742..16ec70e 100644
--- a/runtimes/google/naming/namespace/namespace.go
+++ b/runtimes/google/naming/namespace/namespace.go
@@ -6,7 +6,6 @@
inaming "veyron.io/veyron/veyron/runtimes/google/naming"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/verror"
"veyron.io/veyron/veyron2/vlog"
@@ -18,7 +17,6 @@
// namespace is an implementation of naming.Namespace.
type namespace struct {
sync.RWMutex
- rt veyron2.Runtime
// the default root servers for resolutions in this namespace.
roots []string
@@ -45,13 +43,12 @@
}
// Create a new namespace.
-func New(rt veyron2.Runtime, roots ...string) (*namespace, error) {
+func New(roots ...string) (*namespace, error) {
if !rooted(roots) {
return nil, badRoots(roots)
}
// A namespace with no roots can still be used for lookups of rooted names.
return &namespace{
- rt: rt,
roots: roots,
maxResolveDepth: defaultMaxResolveDepth,
maxRecursiveGlobDepth: defaultMaxRecursiveGlobDepth,
diff --git a/runtimes/google/naming/namespace/resolve.go b/runtimes/google/naming/namespace/resolve.go
index 8647590..d010811 100644
--- a/runtimes/google/naming/namespace/resolve.go
+++ b/runtimes/google/naming/namespace/resolve.go
@@ -5,6 +5,7 @@
"fmt"
"runtime"
+ "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/context"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
@@ -80,6 +81,7 @@
return nil, verror.Make(naming.ErrNoSuchName, ctx, name)
}
pattern := getRootPattern(opts)
+ client := veyron2.RuntimeFromContext(ctx).Client()
// Iterate walking through mount table servers.
for remaining := ns.maxResolveDepth; remaining > 0; remaining-- {
vlog.VI(2).Infof("ResolveX(%s) loop %v", name, *e)
@@ -89,7 +91,7 @@
}
var err error
curr := e
- if e, err = ns.resolveAgainstMountTable(ctx, ns.rt.Client(), curr, pattern); err != nil {
+ if e, err = ns.resolveAgainstMountTable(ctx, client, curr, pattern); err != nil {
// Lots of reasons why another error can happen. We are trying
// to single out "this isn't a mount table".
if notAnMT(err) {
@@ -130,6 +132,7 @@
return nil, verror.Make(naming.ErrNoMountTable, ctx)
}
pattern := getRootPattern(opts)
+ client := veyron2.RuntimeFromContext(ctx).Client()
last := e
for remaining := ns.maxResolveDepth; remaining > 0; remaining-- {
vlog.VI(2).Infof("ResolveToMountTableX(%s) loop %v", name, e)
@@ -140,7 +143,7 @@
vlog.VI(1).Infof("ResolveToMountTableX(%s) -> %v", name, last)
return last, nil
}
- if e, err = ns.resolveAgainstMountTable(ctx, ns.rt.Client(), e, pattern); err != nil {
+ if e, err = ns.resolveAgainstMountTable(ctx, client, e, pattern); err != nil {
if verror.Is(err, naming.ErrNoSuchNameRoot.ID) {
vlog.VI(1).Infof("ResolveToMountTableX(%s) -> %v (NoSuchRoot: %v)", name, last, curr)
return last, nil
@@ -224,10 +227,11 @@
if err != nil {
return nil, err
}
+ client := veyron2.RuntimeFromContext(ctx).Client()
for remaining := ns.maxResolveDepth; remaining > 0; remaining-- {
vlog.VI(2).Infof("Unresolve loop %s", names)
curr := names
- if names, err = unresolveAgainstServer(ctx, ns.rt.Client(), names); err != nil {
+ if names, err = unresolveAgainstServer(ctx, client, names); err != nil {
return nil, err
}
if len(names) == 0 {
diff --git a/runtimes/google/rt/rt.go b/runtimes/google/rt/rt.go
index ab635b2..e91f6f8 100644
--- a/runtimes/google/rt/rt.go
+++ b/runtimes/google/rt/rt.go
@@ -97,7 +97,7 @@
vlog.VI(1).Infof("Using profile %q", rt.profile.Name())
}
- if ns, err := namespace.New(rt, rt.flags.NamespaceRoots...); err != nil {
+ if ns, err := namespace.New(rt.flags.NamespaceRoots...); err != nil {
return nil, fmt.Errorf("Couldn't create mount table: %v", err)
} else {
rt.ns = ns