TBR namespace: Add opts to each call that has underlying RPCs
to pass CallOpts to those RPCs.
MultiPart: 2/2
Change-Id: I7a25bbce2c3aa9303bfafb57e4dd14a53ad88a9b
diff --git a/cmd/namespace/impl.go b/cmd/namespace/impl.go
index 113b909..5e9ac2b 100644
--- a/cmd/namespace/impl.go
+++ b/cmd/namespace/impl.go
@@ -155,7 +155,7 @@
ns := v23.GetNamespace(ctx)
- var opts []naming.ResolveOpt
+ var opts []naming.NamespaceOpt
if flagInsecureResolve {
opts = append(opts, options.SkipServerEndpointAuthorization{})
}
@@ -189,7 +189,7 @@
defer cancel()
ns := v23.GetNamespace(ctx)
- var opts []naming.ResolveOpt
+ var opts []naming.NamespaceOpt
if flagInsecureResolveToMT {
opts = append(opts, options.SkipServerEndpointAuthorization{})
}
diff --git a/profiles/internal/lib/publisher/publisher.go b/profiles/internal/lib/publisher/publisher.go
index 1121e55..b067f05 100644
--- a/profiles/internal/lib/publisher/publisher.go
+++ b/profiles/internal/lib/publisher/publisher.go
@@ -301,7 +301,7 @@
// to sync will occur within the next period, and refresh all mounts.
ttl := ps.period + mountTTLSlack
status.LastMount = time.Now()
- status.LastMountErr = ps.ns.Mount(ps.ctx, name, server, ttl, naming.ServesMountTableOpt(attr.servesMT), naming.IsLeafOpt(attr.isLeaf))
+ status.LastMountErr = ps.ns.Mount(ps.ctx, name, server, ttl, naming.ServesMountTable(attr.servesMT), naming.IsLeaf(attr.isLeaf))
status.TTL = ttl
if status.LastMountErr != nil {
vlog.Errorf("rpc pub: couldn't mount(%v, %v, %v): %v", name, server, ttl, status.LastMountErr)
diff --git a/profiles/internal/naming/endpoint_test.go b/profiles/internal/naming/endpoint_test.go
index 1cd985e..a011512 100644
--- a/profiles/internal/naming/endpoint_test.go
+++ b/profiles/internal/naming/endpoint_test.go
@@ -163,7 +163,7 @@
} else {
ep, err = NewEndpoint(naming.FormatEndpoint(naming.UnknownProtocol, str,
version.RPCVersionRange{test.min, test.max},
- naming.ServesMountTableOpt(test.servesMT)))
+ naming.ServesMountTable(test.servesMT)))
}
if err != nil {
t.Errorf("Endpoint(%q) failed with %v", str, err)
diff --git a/profiles/internal/naming/namespace/acl.go b/profiles/internal/naming/namespace/acl.go
index 61f6a0d..d47e4ea 100644
--- a/profiles/internal/naming/namespace/acl.go
+++ b/profiles/internal/naming/namespace/acl.go
@@ -7,6 +7,7 @@
import (
"v.io/v23"
"v.io/v23/context"
+ "v.io/v23/naming"
"v.io/v23/options"
"v.io/v23/rpc"
"v.io/v23/security/access"
@@ -14,10 +15,10 @@
)
// setAccessListInMountTable sets the AccessList in a single server.
-func setAccessListInMountTable(ctx *context.T, client rpc.Client, name string, acl access.Permissions, etag, id string) (s status) {
+func setAccessListInMountTable(ctx *context.T, client rpc.Client, name string, acl access.Permissions, etag, id string, opts []rpc.CallOpt) (s status) {
s.id = id
ctx, _ = context.WithTimeout(ctx, callTimeout)
- call, err := client.StartCall(ctx, name, "SetPermissions", []interface{}{acl, etag}, options.NoResolve{})
+ call, err := client.StartCall(ctx, name, "SetPermissions", []interface{}{acl, etag}, append(opts, options.NoResolve{})...)
s.err = err
if err != nil {
return
@@ -26,33 +27,33 @@
return
}
-func (ns *namespace) SetPermissions(ctx *context.T, name string, acl access.Permissions, etag string) error {
+func (ns *namespace) SetPermissions(ctx *context.T, name string, acl access.Permissions, etag string, opts ...naming.NamespaceOpt) error {
defer vlog.LogCall()()
client := v23.GetClient(ctx)
// Apply to all mount tables implementing the name.
f := func(ctx *context.T, mt, id string) status {
- return setAccessListInMountTable(ctx, client, mt, acl, etag, id)
+ return setAccessListInMountTable(ctx, client, mt, acl, etag, id, getCallOpts(opts))
}
- err := ns.dispatch(ctx, name, f)
+ err := ns.dispatch(ctx, name, f, opts)
vlog.VI(1).Infof("SetPermissions(%s, %v, %s) -> %v", name, acl, etag, err)
return err
}
// GetPermissions gets an AccessList from a mount table.
-func (ns *namespace) GetPermissions(ctx *context.T, name string) (acl access.Permissions, etag string, err error) {
+func (ns *namespace) GetPermissions(ctx *context.T, name string, opts ...naming.NamespaceOpt) (acl access.Permissions, etag string, err error) {
defer vlog.LogCall()()
client := v23.GetClient(ctx)
// Resolve to all the mount tables implementing name.
- me, rerr := ns.ResolveToMountTable(ctx, name)
+ me, rerr := ns.ResolveToMountTable(ctx, name, opts...)
if rerr != nil {
err = rerr
return
}
mts := me.Names()
- call, serr := ns.parallelStartCall(ctx, client, mts, "GetPermissions", []interface{}{})
+ call, serr := ns.parallelStartCall(ctx, client, mts, "GetPermissions", []interface{}{}, getCallOpts(opts))
if serr != nil {
err = serr
return
diff --git a/profiles/internal/naming/namespace/acl_test.go b/profiles/internal/naming/namespace/acl_test.go
index d64b009..74e60c2 100644
--- a/profiles/internal/naming/namespace/acl_test.go
+++ b/profiles/internal/naming/namespace/acl_test.go
@@ -129,10 +129,10 @@
defer stop2()
// Mount them into the root.
- if err := ns.Mount(rootCtx, "a/b/c", mt1Addr, 0, naming.ServesMountTableOpt(true)); err != nil {
+ if err := ns.Mount(rootCtx, "a/b/c", mt1Addr, 0, naming.ServesMountTable(true)); err != nil {
t.Fatalf("Failed to Mount %s onto a/b/c: %s", "/"+mt1Addr, err)
}
- if err := ns.Mount(rootCtx, "a/b/c", mt2Addr, 0, naming.ServesMountTableOpt(true)); err != nil {
+ if err := ns.Mount(rootCtx, "a/b/c", mt2Addr, 0, naming.ServesMountTable(true)); err != nil {
t.Fatalf("Failed to Mount %s onto a/b/c: %s", "/"+mt2Addr, err)
}
diff --git a/profiles/internal/naming/namespace/all_test.go b/profiles/internal/naming/namespace/all_test.go
index c8981c9..3c21423 100644
--- a/profiles/internal/naming/namespace/all_test.go
+++ b/profiles/internal/naming/namespace/all_test.go
@@ -148,7 +148,7 @@
}
}
-func doResolveTest(t *testing.T, fname string, f func(*context.T, string, ...naming.ResolveOpt) (*naming.MountEntry, error), ctx *context.T, name string, want []string, opts ...naming.ResolveOpt) {
+func doResolveTest(t *testing.T, fname string, f func(*context.T, string, ...naming.NamespaceOpt) (*naming.MountEntry, error), ctx *context.T, name string, want []string, opts ...naming.NamespaceOpt) {
me, err := f(ctx, name, opts...)
if err != nil {
boom(t, "Failed to %s %s: %s", fname, name, err)
@@ -160,7 +160,7 @@
doResolveTest(t, "ResolveToMountTable", ns.ResolveToMountTable, ctx, name, want)
}
-func testResolveToMountTableWithPattern(t *testing.T, ctx *context.T, ns ns.Namespace, name string, pattern naming.ResolveOpt, want ...string) {
+func testResolveToMountTableWithPattern(t *testing.T, ctx *context.T, ns ns.Namespace, name string, pattern naming.NamespaceOpt, want ...string) {
doResolveTest(t, "ResolveToMountTable", ns.ResolveToMountTable, ctx, name, want, pattern)
}
@@ -168,7 +168,7 @@
doResolveTest(t, "Resolve", ns.Resolve, ctx, name, want)
}
-func testResolveWithPattern(t *testing.T, ctx *context.T, ns ns.Namespace, name string, pattern naming.ResolveOpt, want ...string) {
+func testResolveWithPattern(t *testing.T, ctx *context.T, ns ns.Namespace, name string, pattern naming.NamespaceOpt, want ...string) {
doResolveTest(t, "Resolve", ns.Resolve, ctx, name, want, pattern)
}
@@ -352,7 +352,7 @@
{"mt2", mts[mt4MP].name},
{"mt2//", mts[mt5MP].name},
} {
- if err := ns.Mount(c, mp.name, mp.server, ttl, naming.ServesMountTableOpt(true)); err != nil {
+ if err := ns.Mount(c, mp.name, mp.server, ttl, naming.ServesMountTable(true)); err != nil {
boom(t, "Failed to Mount %s: %s", mp.name, err)
}
}
@@ -546,17 +546,17 @@
defer c3.server.Stop()
m := "c1/c2"
- if err := ns.Mount(c, m, c1.name, ttl, naming.ServesMountTableOpt(true)); err != nil {
+ if err := ns.Mount(c, m, c1.name, ttl, naming.ServesMountTable(true)); err != nil {
boom(t, "Failed to Mount %s: %s", "c1/c2", err)
}
m = "c1/c2/c3"
- if err := ns.Mount(c, m, c3.name, ttl, naming.ServesMountTableOpt(true)); err != nil {
+ if err := ns.Mount(c, m, c3.name, ttl, naming.ServesMountTable(true)); err != nil {
boom(t, "Failed to Mount %s: %s", m, err)
}
m = "c1/c3/c4"
- if err := ns.Mount(c, m, c1.name, ttl, naming.ServesMountTableOpt(true)); err != nil {
+ if err := ns.Mount(c, m, c1.name, ttl, naming.ServesMountTable(true)); err != nil {
boom(t, "Failed to Mount %s: %s", m, err)
}
@@ -628,11 +628,11 @@
idp = testutil.NewIDProvider("idp") // identity provider
serverEndpoint = naming.FormatEndpoint("tcp", "127.0.0.1:14141")
- resolve = func(name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
+ resolve = func(name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
return v23.GetNamespace(clientCtx).Resolve(clientCtx, name, opts...)
}
- mount = func(name, server string, ttl time.Duration, opts ...naming.MountOpt) error {
+ mount = func(name, server string, ttl time.Duration, opts ...naming.NamespaceOpt) error {
return v23.GetNamespace(serverCtx).Mount(serverCtx, name, server, ttl, opts...)
}
)
@@ -654,7 +654,7 @@
// Intermediate mounttables should be authenticated.
mt := runMT(t, mtCtx, "mt")
// Mount a server on "mt".
- if err := mount("mt/server", serverEndpoint, time.Minute, naming.ReplaceMountOpt(true)); err != nil {
+ if err := mount("mt/server", serverEndpoint, time.Minute, naming.ReplaceMount(true)); err != nil {
t.Error(err)
}
// The namespace root should be authenticated too
@@ -664,7 +664,7 @@
// Host:Port and Endpoint versions of the other namespace root
// (which has different blessings)
hproot := fmt.Sprintf("(otherroot)@%v", rootmt.endpoint.Addr())
- eproot := naming.FormatEndpoint(rootmt.endpoint.Addr().Network(), rootmt.endpoint.Addr().String(), rootmt.endpoint.RoutingID(), naming.BlessingOpt("otherroot"), naming.ServesMountTableOpt(rootmt.endpoint.ServesMountTable()))
+ eproot := naming.FormatEndpoint(rootmt.endpoint.Addr().Network(), rootmt.endpoint.Addr().String(), rootmt.endpoint.RoutingID(), naming.BlessingOpt("otherroot"), naming.ServesMountTable(rootmt.endpoint.ServesMountTable()))
for _, root := range []string{hproot, eproot} {
name := naming.JoinAddressName(root, "mt")
// Rooted name resolutions should fail authorization because of the "otherrot"
@@ -691,7 +691,7 @@
// global mounttable) having inconsistent blessings. Simulate this by
// explicitly changing the mount entry for "mt".
goodChildMTEndpoint := naming.FormatEndpoint(mt.endpoint.Addr().Network(), mt.endpoint.Addr().String(), naming.BlessingOpt("idp/goodchildmt"), mt.endpoint.RoutingID())
- if err := v23.GetNamespace(mtCtx).Mount(mtCtx, "mt", goodChildMTEndpoint, time.Minute, naming.ServesMountTableOpt(true), naming.ReplaceMountOpt(true)); err != nil {
+ if err := v23.GetNamespace(mtCtx).Mount(mtCtx, "mt", goodChildMTEndpoint, time.Minute, naming.ServesMountTable(true), naming.ReplaceMount(true)); err != nil {
t.Error(err)
}
diff --git a/profiles/internal/naming/namespace/glob.go b/profiles/internal/naming/namespace/glob.go
index 16cdc11..e0c26e0 100644
--- a/profiles/internal/naming/namespace/glob.go
+++ b/profiles/internal/naming/namespace/glob.go
@@ -50,7 +50,7 @@
// globAtServer performs a Glob on the servers at a mount point. It cycles through the set of
// servers until it finds one that replies.
-func (ns *namespace) globAtServer(ctx *context.T, t *task, replies chan *task, tr *tracks) {
+func (ns *namespace) globAtServer(ctx *context.T, t *task, replies chan *task, tr *tracks, opts []rpc.CallOpt) {
defer func() {
if t.error == nil {
replies <- nil
@@ -80,7 +80,7 @@
return
}
- call, err := ns.parallelStartCall(ctx, client, servers, rpc.GlobMethod, []interface{}{pstr})
+ call, err := ns.parallelStartCall(ctx, client, servers, rpc.GlobMethod, []interface{}{pstr}, opts)
if err != nil {
t.error = err
return
@@ -146,7 +146,7 @@
}
// globLoop fires off a go routine for each server and read backs replies.
-func (ns *namespace) globLoop(ctx *context.T, e *naming.MountEntry, prefix string, pattern *glob.Glob, reply chan interface{}, tr *tracks) {
+func (ns *namespace) globLoop(ctx *context.T, e *naming.MountEntry, prefix string, pattern *glob.Glob, reply chan interface{}, tr *tracks, opts []rpc.CallOpt) {
defer close(reply)
// Provide enough buffers to avoid too much switching between the readers and the writers.
@@ -228,13 +228,13 @@
// Perform a glob at the next server.
inFlight++
t.pattern = suffix
- go ns.globAtServer(ctx, t, replies, tr)
+ go ns.globAtServer(ctx, t, replies, tr, opts)
}
}
}
// Glob implements naming.MountTable.Glob.
-func (ns *namespace) Glob(ctx *context.T, pattern string) (chan interface{}, error) {
+func (ns *namespace) Glob(ctx *context.T, pattern string, opts ...naming.NamespaceOpt) (chan interface{}, error) {
defer vlog.LogCall()()
// Root the pattern. If we have no servers to query, give up.
e, patternWasRooted := ns.rootMountEntry(pattern)
@@ -259,6 +259,6 @@
}
e.Name = ""
reply := make(chan interface{}, 100)
- go ns.globLoop(ctx, e, prefix, g, reply, tr)
+ go ns.globLoop(ctx, e, prefix, g, reply, tr, getCallOpts(opts))
return reply, nil
}
diff --git a/profiles/internal/naming/namespace/mount.go b/profiles/internal/naming/namespace/mount.go
index 7c28c28..6e9d87b 100644
--- a/profiles/internal/naming/namespace/mount.go
+++ b/profiles/internal/naming/namespace/mount.go
@@ -17,10 +17,10 @@
)
// mountIntoMountTable mounts a single server into a single mount table.
-func mountIntoMountTable(ctx *context.T, client rpc.Client, name, server string, ttl time.Duration, flags naming.MountFlag, id string) (s status) {
+func mountIntoMountTable(ctx *context.T, client rpc.Client, name, server string, ttl time.Duration, flags naming.MountFlag, id string, opts ...rpc.CallOpt) (s status) {
s.id = id
ctx, _ = context.WithTimeout(ctx, callTimeout)
- call, err := client.StartCall(ctx, name, "Mount", []interface{}{server, uint32(ttl.Seconds()), flags}, options.NoResolve{})
+ call, err := client.StartCall(ctx, name, "Mount", []interface{}{server, uint32(ttl.Seconds()), flags}, append(opts, options.NoResolve{})...)
s.err = err
if err != nil {
return
@@ -30,22 +30,22 @@
}
// Mount implements Namespace.Mount.
-func (ns *namespace) Mount(ctx *context.T, name, server string, ttl time.Duration, opts ...naming.MountOpt) error {
+func (ns *namespace) Mount(ctx *context.T, name, server string, ttl time.Duration, opts ...naming.NamespaceOpt) error {
defer vlog.LogCall()()
var flags naming.MountFlag
for _, o := range opts {
// NB: used a switch since we'll be adding more options.
switch v := o.(type) {
- case naming.ReplaceMountOpt:
+ case naming.ReplaceMount:
if v {
flags |= naming.MountFlag(naming.Replace)
}
- case naming.ServesMountTableOpt:
+ case naming.ServesMountTable:
if v {
flags |= naming.MountFlag(naming.MT)
}
- case naming.IsLeafOpt:
+ case naming.IsLeaf:
if v {
flags |= naming.MountFlag(naming.Leaf)
}
@@ -55,18 +55,18 @@
client := v23.GetClient(ctx)
// Mount the server in all the returned mount tables.
f := func(ctx *context.T, mt, id string) status {
- return mountIntoMountTable(ctx, client, mt, server, ttl, flags, id)
+ return mountIntoMountTable(ctx, client, mt, server, ttl, flags, id, getCallOpts(opts)...)
}
- err := ns.dispatch(ctx, name, f)
+ err := ns.dispatch(ctx, name, f, opts)
vlog.VI(1).Infof("Mount(%s, %q) -> %v", name, server, err)
return err
}
// unmountFromMountTable removes a single mounted server from a single mount table.
-func unmountFromMountTable(ctx *context.T, client rpc.Client, name, server string, id string) (s status) {
+func unmountFromMountTable(ctx *context.T, client rpc.Client, name, server string, id string, opts ...rpc.CallOpt) (s status) {
s.id = id
ctx, _ = context.WithTimeout(ctx, callTimeout)
- call, err := client.StartCall(ctx, name, "Unmount", []interface{}{server}, options.NoResolve{})
+ call, err := client.StartCall(ctx, name, "Unmount", []interface{}{server}, append(opts, options.NoResolve{})...)
s.err = err
if err != nil {
return
@@ -76,24 +76,24 @@
}
// Unmount implements Namespace.Unmount.
-func (ns *namespace) Unmount(ctx *context.T, name, server string) error {
+func (ns *namespace) Unmount(ctx *context.T, name, server string, opts ...naming.NamespaceOpt) error {
defer vlog.LogCall()()
// Unmount the server from all the mount tables.
client := v23.GetClient(ctx)
f := func(ctx *context.T, mt, id string) status {
- return unmountFromMountTable(ctx, client, mt, server, id)
+ return unmountFromMountTable(ctx, client, mt, server, id, getCallOpts(opts)...)
}
- err := ns.dispatch(ctx, name, f)
+ err := ns.dispatch(ctx, name, f, opts)
vlog.VI(1).Infof("Unmount(%s, %s) -> %v", name, server, err)
return err
}
// deleteFromMountTable deletes a name from a single mount table. If there are any children
// and deleteSubtree isn't true, nothing is deleted.
-func deleteFromMountTable(ctx *context.T, client rpc.Client, name string, deleteSubtree bool, id string) (s status) {
+func deleteFromMountTable(ctx *context.T, client rpc.Client, name string, deleteSubtree bool, id string, opts ...rpc.CallOpt) (s status) {
s.id = id
ctx, _ = context.WithTimeout(ctx, callTimeout)
- call, err := client.StartCall(ctx, name, "Delete", []interface{}{deleteSubtree}, options.NoResolve{})
+ call, err := client.StartCall(ctx, name, "Delete", []interface{}{deleteSubtree}, append(opts, options.NoResolve{})...)
s.err = err
if err != nil {
return
@@ -103,14 +103,14 @@
}
// RDeleteemove implements Namespace.Delete.
-func (ns *namespace) Delete(ctx *context.T, name string, deleteSubtree bool) error {
+func (ns *namespace) Delete(ctx *context.T, name string, deleteSubtree bool, opts ...naming.NamespaceOpt) error {
defer vlog.LogCall()()
// Remove from all the mount tables.
client := v23.GetClient(ctx)
f := func(ctx *context.T, mt, id string) status {
- return deleteFromMountTable(ctx, client, mt, deleteSubtree, id)
+ return deleteFromMountTable(ctx, client, mt, deleteSubtree, id, getCallOpts(opts)...)
}
- err := ns.dispatch(ctx, name, f)
+ err := ns.dispatch(ctx, name, f, opts)
vlog.VI(1).Infof("Remove(%s, %v) -> %v", name, deleteSubtree, err)
return err
}
diff --git a/profiles/internal/naming/namespace/namespace.go b/profiles/internal/naming/namespace/namespace.go
index 8d652a9..13311bd 100644
--- a/profiles/internal/naming/namespace/namespace.go
+++ b/profiles/internal/naming/namespace/namespace.go
@@ -11,6 +11,7 @@
inaming "v.io/x/ref/profiles/internal/naming"
"v.io/v23/naming"
+ "v.io/v23/rpc"
"v.io/v23/security"
vdltime "v.io/v23/vdlroot/time"
"v.io/v23/verror"
@@ -126,7 +127,7 @@
// (1) MountEntry
// (2) Whether "name" is a rooted name or not (if not, the namespace roots
// configured in "ns" will be used).
-func (ns *namespace) rootMountEntry(name string, opts ...naming.ResolveOpt) (*naming.MountEntry, bool) {
+func (ns *namespace) rootMountEntry(name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, bool) {
_, name = security.SplitPatternName(naming.Clean(name))
e := new(naming.MountEntry)
deadline := vdltime.Deadline{time.Now().Add(time.Hour)} // plenty of time for a call
@@ -198,3 +199,13 @@
}
return nil
}
+
+func getCallOpts(opts []naming.NamespaceOpt) []rpc.CallOpt {
+ var out []rpc.CallOpt
+ for _, o := range opts {
+ if co, ok := o.(rpc.CallOpt); ok {
+ out = append(out, co)
+ }
+ }
+ return out
+}
diff --git a/profiles/internal/naming/namespace/parallelstartcall.go b/profiles/internal/naming/namespace/parallelstartcall.go
index 611d742..f753e4e 100644
--- a/profiles/internal/naming/namespace/parallelstartcall.go
+++ b/profiles/internal/naming/namespace/parallelstartcall.go
@@ -19,13 +19,13 @@
call rpc.ClientCall
}
-func tryStartCall(ctx *context.T, client rpc.Client, target, method string, args []interface{}, c chan startStatus, index int) {
- call, err := client.StartCall(ctx, target, method, args, options.NoResolve{})
+func tryStartCall(ctx *context.T, client rpc.Client, target, method string, args []interface{}, c chan startStatus, index int, opts ...rpc.CallOpt) {
+ call, err := client.StartCall(ctx, target, method, args, append(opts, options.NoResolve{})...)
c <- startStatus{index: index, err: err, call: call}
}
// parallelStartCall returns the first succeeding StartCall.
-func (ns *namespace) parallelStartCall(ctx *context.T, client rpc.Client, servers []string, method string, args []interface{}) (rpc.ClientCall, error) {
+func (ns *namespace) parallelStartCall(ctx *context.T, client rpc.Client, servers []string, method string, args []interface{}, opts []rpc.CallOpt) (rpc.ClientCall, error) {
if len(servers) == 0 {
return nil, verror.New(verror.ErrNoExist, ctx, "no servers to resolve query")
}
@@ -36,7 +36,7 @@
for index, server := range servers {
callCtx, cancel := context.WithTimeout(ctx, callTimeout)
cancelFuncs[index] = cancel
- go tryStartCall(callCtx, client, server, method, args, c, index)
+ go tryStartCall(callCtx, client, server, method, args, c, index, opts...)
}
// First positive response wins. Cancel the rest. The cancellation
@@ -101,7 +101,7 @@
}
// dispatch executes f in parallel for each mount table implementing mTName.
-func (ns *namespace) dispatch(ctx *context.T, mTName string, f func(*context.T, string, string) status, opts ...naming.ResolveOpt) error {
+func (ns *namespace) dispatch(ctx *context.T, mTName string, f func(*context.T, string, string) status, opts []naming.NamespaceOpt) error {
// Resolve to all the mount tables implementing name.
me, err := ns.ResolveToMountTable(ctx, mTName, opts...)
if err != nil {
diff --git a/profiles/internal/naming/namespace/resolve.go b/profiles/internal/naming/namespace/resolve.go
index e38df59..a813577 100644
--- a/profiles/internal/naming/namespace/resolve.go
+++ b/profiles/internal/naming/namespace/resolve.go
@@ -65,7 +65,7 @@
}
// Resolve implements v.io/v23/naming.Namespace.
-func (ns *namespace) Resolve(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
+func (ns *namespace) Resolve(ctx *context.T, name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
defer vlog.LogCall()()
e, _ := ns.rootMountEntry(name, opts...)
if vlog.V(2) {
@@ -109,7 +109,7 @@
}
// ResolveToMountTable implements v.io/v23/naming.Namespace.
-func (ns *namespace) ResolveToMountTable(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
+func (ns *namespace) ResolveToMountTable(ctx *context.T, name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
defer vlog.LogCall()()
e, _ := ns.rootMountEntry(name, opts...)
if vlog.V(2) {
@@ -182,7 +182,7 @@
return flushed
}
-func skipResolve(opts []naming.ResolveOpt) bool {
+func skipResolve(opts []naming.NamespaceOpt) bool {
for _, o := range opts {
if _, ok := o.(options.NoResolve); ok {
return true
@@ -190,13 +190,3 @@
}
return false
}
-
-func getCallOpts(opts []naming.ResolveOpt) []rpc.CallOpt {
- var out []rpc.CallOpt
- for _, o := range opts {
- if co, ok := o.(rpc.CallOpt); ok {
- out = append(out, co)
- }
- }
- return out
-}
diff --git a/profiles/internal/rpc/client.go b/profiles/internal/rpc/client.go
index 9905f55..603f60f 100644
--- a/profiles/internal/rpc/client.go
+++ b/profiles/internal/rpc/client.go
@@ -273,7 +273,7 @@
shouldRetry = false
case time.Now().After(deadline):
shouldRetry = false
- case action == verror.RetryRefetch && getNoResolveOpt(opts):
+ case action == verror.RetryRefetch && getNoNamespaceOpt(opts):
// If we're skipping resolution and there are no servers for
// this call retrying is not going to help, we can't come up
// with new servers if there is no resolution.
@@ -373,7 +373,7 @@
var err error
var blessingPattern security.BlessingPattern
blessingPattern, name = security.SplitPatternName(name)
- if resolved, err = c.ns.Resolve(ctx, name, getResolveOpts(opts)...); err != nil {
+ if resolved, err = c.ns.Resolve(ctx, name, getNamespaceOpts(opts)...); err != nil {
vlog.Errorf("Resolve: %v", err)
// We always return NoServers as the error so that the caller knows
// that's ok to retry the operation since the name may be registered
diff --git a/profiles/internal/rpc/discharges.go b/profiles/internal/rpc/discharges.go
index cb832ea..60ef4bc 100644
--- a/profiles/internal/rpc/discharges.go
+++ b/profiles/internal/rpc/discharges.go
@@ -23,8 +23,8 @@
// NoDischarges specifies that the RPC call should not fetch discharges.
type NoDischarges struct{}
-func (NoDischarges) RPCCallOpt() {}
-func (NoDischarges) NSResolveOpt() {}
+func (NoDischarges) RPCCallOpt() {}
+func (NoDischarges) NSOpt() {}
// discharger implements vc.DischargeClient.
type dischargeClient struct {
diff --git a/profiles/internal/rpc/options.go b/profiles/internal/rpc/options.go
index 3ff7109..27a6fe1 100644
--- a/profiles/internal/rpc/options.go
+++ b/profiles/internal/rpc/options.go
@@ -44,7 +44,7 @@
return 0, false
}
-func getNoResolveOpt(opts []rpc.CallOpt) bool {
+func getNoNamespaceOpt(opts []rpc.CallOpt) bool {
for _, o := range opts {
if _, ok := o.(options.NoResolve); ok {
return true
@@ -80,9 +80,9 @@
return
}
-func getResolveOpts(opts []rpc.CallOpt) (resolveOpts []naming.ResolveOpt) {
+func getNamespaceOpts(opts []rpc.CallOpt) (resolveOpts []naming.NamespaceOpt) {
for _, o := range opts {
- if r, ok := o.(naming.ResolveOpt); ok {
+ if r, ok := o.(naming.NamespaceOpt); ok {
resolveOpts = append(resolveOpts, r)
}
}
diff --git a/profiles/internal/testing/mocks/naming/namespace.go b/profiles/internal/testing/mocks/naming/namespace.go
index 39dde7a..3b4bfc9 100644
--- a/profiles/internal/testing/mocks/naming/namespace.go
+++ b/profiles/internal/testing/mocks/naming/namespace.go
@@ -39,7 +39,7 @@
ns ns.Namespace
}
-func (ns *namespace) Mount(ctx *context.T, name, server string, _ time.Duration, opts ...naming.MountOpt) error {
+func (ns *namespace) Mount(ctx *context.T, name, server string, _ time.Duration, opts ...naming.NamespaceOpt) error {
defer vlog.LogCall()()
ns.Lock()
defer ns.Unlock()
@@ -57,7 +57,7 @@
return nil
}
-func (ns *namespace) Unmount(ctx *context.T, name, server string) error {
+func (ns *namespace) Unmount(ctx *context.T, name, server string, opts ...naming.NamespaceOpt) error {
defer vlog.LogCall()()
ns.Lock()
defer ns.Unlock()
@@ -83,7 +83,7 @@
return nil
}
-func (ns *namespace) Delete(ctx *context.T, name string, removeSubtree bool) error {
+func (ns *namespace) Delete(ctx *context.T, name string, removeSubtree bool, opts ...naming.NamespaceOpt) error {
defer vlog.LogCall()()
ns.Lock()
defer ns.Unlock()
@@ -103,7 +103,7 @@
return nil
}
-func (ns *namespace) Resolve(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
+func (ns *namespace) Resolve(ctx *context.T, name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
defer vlog.LogCall()()
_, name = security.SplitPatternName(name)
if address, suffix := naming.SplitAddressName(name); len(address) > 0 {
@@ -124,7 +124,7 @@
return nil, verror.New(naming.ErrNoSuchName, ctx, fmt.Sprintf("Resolve name %q not found in %v", name, ns.mounts))
}
-func (ns *namespace) ResolveToMountTable(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
+func (ns *namespace) ResolveToMountTable(ctx *context.T, name string, opts ...naming.NamespaceOpt) (*naming.MountEntry, error) {
defer vlog.LogCall()()
// TODO(mattr): Implement this method for tests that might need it.
panic("ResolveToMountTable not implemented")
@@ -141,7 +141,7 @@
return nil
}
-func (ns *namespace) Glob(ctx *context.T, pattern string) (chan interface{}, error) {
+func (ns *namespace) Glob(ctx *context.T, pattern string, opts ...naming.NamespaceOpt) (chan interface{}, error) {
defer vlog.LogCall()()
// TODO(mattr): Implement this method for tests that might need it.
panic("Glob not implemented")
@@ -160,13 +160,13 @@
return nil
}
-func (ns *namespace) GetPermissions(ctx *context.T, name string) (acl access.Permissions, etag string, err error) {
+func (ns *namespace) GetPermissions(ctx *context.T, name string, opts ...naming.NamespaceOpt) (acl access.Permissions, etag string, err error) {
defer vlog.LogCall()()
panic("Calling GetPermissions on a mock namespace. This is not supported.")
return nil, "", nil
}
-func (ns *namespace) SetPermissions(ctx *context.T, name string, acl access.Permissions, etag string) error {
+func (ns *namespace) SetPermissions(ctx *context.T, name string, acl access.Permissions, etag string, opts ...naming.NamespaceOpt) error {
defer vlog.LogCall()()
panic("Calling SetPermissions on a mock namespace. This is not supported.")
return nil
diff --git a/services/mgmt/device/starter/starter.go b/services/mgmt/device/starter/starter.go
index 3bfbf2a..2128cf2 100644
--- a/services/mgmt/device/starter/starter.go
+++ b/services/mgmt/device/starter/starter.go
@@ -343,7 +343,7 @@
for _, root := range ns.Roots() {
go func(r string) {
for {
- err := ns.Mount(ctx, naming.Join(localMT, "global"), r, 0 /* forever */, naming.ServesMountTableOpt(true))
+ err := ns.Mount(ctx, naming.Join(localMT, "global"), r, 0 /* forever */, naming.ServesMountTable(true))
if err == nil {
break
}
@@ -387,7 +387,7 @@
origep.Addr().String(),
origep.RoutingID(),
origep.RPCVersionRange(),
- naming.ServesMountTableOpt(origep.ServesMountTable()))
+ naming.ServesMountTable(origep.ServesMountTable()))
roots[i] = naming.JoinAddressName(ep, suffix)
}
vlog.Infof("Changing namespace roots from %v to %v", origroots, roots)
diff --git a/services/wsprd/namespace/request_handler.go b/services/wsprd/namespace/request_handler.go
index 79629c9..3df6813 100644
--- a/services/wsprd/namespace/request_handler.go
+++ b/services/wsprd/namespace/request_handler.go
@@ -49,7 +49,7 @@
}
func (s *Server) Mount(call rpc.ServerCall, name, server string, ttl time.Duration, replace bool) error {
- rmOpt := naming.ReplaceMountOpt(replace)
+ rmOpt := naming.ReplaceMount(replace)
err := s.ns.Mount(call.Context(), name, server, ttl, rmOpt)
if err != nil {
err = verror.Convert(verror.ErrInternal, call.Context(), err)