Merge "veyron2: make it possible to specify a 'reserved name' dispatcher."
diff --git a/lib/modules/core/echo.go b/lib/modules/core/echo.go
index f3adb9f..8cc7b33 100644
--- a/lib/modules/core/echo.go
+++ b/lib/modules/core/echo.go
@@ -22,7 +22,7 @@
type treeDispatcher struct{ id string }
-func (d treeDispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d treeDispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
return ipc.ReflectInvoker(&echoServerObject{d.id, suffix}), nil, nil
}
diff --git a/runtimes/google/ipc/flow_test.go b/runtimes/google/ipc/flow_test.go
index b78a56f..97ca9cd 100644
--- a/runtimes/google/ipc/flow_test.go
+++ b/runtimes/google/ipc/flow_test.go
@@ -59,7 +59,7 @@
newInvoker func(suffix string) ipc.Invoker
}
-func (td testDisp) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (td testDisp) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
return td.newInvoker(suffix), testServerAuthorizer{}, nil
}
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 67638e1..1e0b892 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -146,7 +146,7 @@
type testServerDisp struct{ server interface{} }
-func (t testServerDisp) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (t testServerDisp) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
// If suffix is "nilAuth" we use default authorization, if it is "aclAuth" we
// use an ACL based authorizer, and otherwise we use the custom testServerAuthorizer.
var authorizer security.Authorizer
@@ -548,7 +548,7 @@
}
// Implements ipc.Dispatcher
-func (s *dischargeImpetusTester) Lookup(_, _ string) (ipc.Invoker, security.Authorizer, error) {
+func (s *dischargeImpetusTester) Lookup(_, _ string) (interface{}, security.Authorizer, error) {
return ipc.ReflectInvoker(s), testServerAuthorizer{}, nil
}
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index 10d4263..8cfa9e9 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -809,11 +809,17 @@
fs.discharges[d.ID()] = d
}
// Lookup the invoker.
- invoker, auth, suffix, verr := fs.lookup(req.Suffix, req.Method)
+ obj, auth, suffix, verr := fs.lookup(req.Suffix, req.Method)
fs.suffix = suffix // with leading /'s stripped
if verr != nil {
return nil, verr
}
+ // TODO(cnicolaou): ipc.Serve TRANSITION
+ invoker, ok := obj.(ipc.Invoker)
+ if !ok {
+ panic("Lookup should have returned an ipc.Invoker")
+ }
+
// Prepare invoker and decode args.
numArgs := int(req.NumPosArgs)
argptrs, label, err := invoker.Prepare(req.Method, numArgs)
@@ -851,7 +857,8 @@
// with ipc.DebugKeyword, we use the internal debug dispatcher to look up the
// invoker. Otherwise, and we use the server's dispatcher. The (stripped) name
// and dispatch suffix are also returned.
-func (fs *flowServer) lookup(name, method string) (ipc.Invoker, security.Authorizer, string, verror.E) {
+// TODO(cnicolaou): change this back returning in ipc.Invoker in the pt2 CL.
+func (fs *flowServer) lookup(name, method string) (interface{}, security.Authorizer, string, verror.E) {
name = strings.TrimLeft(name, "/")
if method == "Glob" && len(name) == 0 {
return ipc.ReflectInvoker(&globInvoker{fs.reservedOpt.Prefix, fs}), &acceptAllAuthorizer{}, name, nil
@@ -913,11 +920,16 @@
if d == nil {
return nil
}
- invoker, auth, err := d.Lookup("", "Glob")
+ obj, auth, err := d.Lookup("", "Glob")
if err != nil {
return err
}
- if invoker == nil {
+ // TODO(cnicolaou): ipc.Serve TRANSITION
+ invoker, ok := obj.(ipc.Invoker)
+ if !ok {
+ panic("Lookup should have returned an ipc.Invoker")
+ }
+ if obj == nil || !ok {
return verror.NoExistf("ipc: invoker not found for Glob")
}
@@ -943,7 +955,7 @@
if res == nil {
return nil
}
- err, ok := res.(error)
+ err, ok = res.(error)
if !ok {
return verror.BadArgf("unexpected result type. Got %T, want error", res)
}
diff --git a/runtimes/google/naming/namespace/all_test.go b/runtimes/google/naming/namespace/all_test.go
index 9c29b25..87c80da 100644
--- a/runtimes/google/naming/namespace/all_test.go
+++ b/runtimes/google/naming/namespace/all_test.go
@@ -118,7 +118,7 @@
type dispatcher struct{}
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
return ipc.ReflectInvoker(&testServer{suffix}), allowEveryoneAuthorizer{}, nil
}
diff --git a/services/identity/identityd/main.go b/services/identity/identityd/main.go
index 2ba0fc2..8a9b860 100644
--- a/services/identity/identityd/main.go
+++ b/services/identity/identityd/main.go
@@ -159,7 +159,7 @@
type dispatcher map[string]ipc.Invoker
-func (d dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
if invoker := d[suffix]; invoker != nil {
return invoker, allowEveryoneAuthorizer{}, nil
}
diff --git a/services/mgmt/application/impl/dispatcher.go b/services/mgmt/application/impl/dispatcher.go
index f2b8793..48b6c4f 100644
--- a/services/mgmt/application/impl/dispatcher.go
+++ b/services/mgmt/application/impl/dispatcher.go
@@ -29,7 +29,7 @@
// DISPATCHER INTERFACE IMPLEMENTATION
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
invoker := ipc.ReflectInvoker(repository.NewServerApplication(NewInvoker(d.store, d.storeRoot, suffix)))
return invoker, d.auth, nil
}
diff --git a/services/mgmt/binary/impl/dispatcher.go b/services/mgmt/binary/impl/dispatcher.go
index dc6ddcb..7f54fb7 100644
--- a/services/mgmt/binary/impl/dispatcher.go
+++ b/services/mgmt/binary/impl/dispatcher.go
@@ -51,7 +51,7 @@
// DISPATCHER INTERFACE IMPLEMENTATION
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
invoker := ipc.ReflectInvoker(repository.NewServerBinary(newInvoker(d.state, suffix)))
return invoker, d.auth, nil
}
diff --git a/services/mgmt/debug/dispatcher.go b/services/mgmt/debug/dispatcher.go
index df7c301..9f03323 100644
--- a/services/mgmt/debug/dispatcher.go
+++ b/services/mgmt/debug/dispatcher.go
@@ -25,7 +25,7 @@
return &dispatcher{logsDir, authorizer}
}
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
if method == "Signature" {
return NewSignatureInvoker(suffix), d.auth, nil
}
diff --git a/services/mgmt/lib/toplevelglob/invoker.go b/services/mgmt/lib/toplevelglob/invoker.go
index 16d1676..5a9a966 100644
--- a/services/mgmt/lib/toplevelglob/invoker.go
+++ b/services/mgmt/lib/toplevelglob/invoker.go
@@ -42,10 +42,15 @@
}
func (i *invoker) leafGlob(call ipc.ServerCall, leaf string, pattern string) error {
- invoker, _, err := i.d.Lookup(leaf, "Glob")
+ obj, _, err := i.d.Lookup(leaf, "Glob")
if err != nil {
return err
}
+ // TODO(cnicolaou): ipc.Serve TRANSITION
+ invoker, ok := obj.(ipc.Invoker)
+ if !ok {
+ panic("Lookup should have returned an ipc.Invoker")
+ }
if invoker == nil {
return verror.BadArgf("failed to find invoker for %q", leaf)
}
@@ -62,7 +67,7 @@
if res == nil {
return nil
}
- err, ok := res.(error)
+ err, ok = res.(error)
if !ok {
return verror.BadArgf("unexpected result type. Got %T, want error", res)
}
diff --git a/services/mgmt/logreader/impl/logdir_invoker_test.go b/services/mgmt/logreader/impl/logdir_invoker_test.go
index 8bd99a3..0cba1db 100644
--- a/services/mgmt/logreader/impl/logdir_invoker_test.go
+++ b/services/mgmt/logreader/impl/logdir_invoker_test.go
@@ -10,7 +10,6 @@
"veyron.io/veyron/veyron/services/mgmt/logreader/impl"
- "veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
@@ -22,7 +21,7 @@
root string
}
-func (d *logDirectoryDispatcher) Lookup(suffix, _ string) (ipc.Invoker, security.Authorizer, error) {
+func (d *logDirectoryDispatcher) Lookup(suffix, _ string) (interface{}, security.Authorizer, error) {
return impl.NewLogDirectoryInvoker(d.root, suffix), nil, nil
}
diff --git a/services/mgmt/logreader/impl/logfile_invoker_test.go b/services/mgmt/logreader/impl/logfile_invoker_test.go
index 06487e2..0cc7615 100644
--- a/services/mgmt/logreader/impl/logfile_invoker_test.go
+++ b/services/mgmt/logreader/impl/logfile_invoker_test.go
@@ -8,7 +8,6 @@
"veyron.io/veyron/veyron/services/mgmt/logreader/impl"
- "veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
@@ -21,7 +20,7 @@
root string
}
-func (d *logFileDispatcher) Lookup(suffix, _ string) (ipc.Invoker, security.Authorizer, error) {
+func (d *logFileDispatcher) Lookup(suffix, _ string) (interface{}, security.Authorizer, error) {
return impl.NewLogFileInvoker(d.root, suffix), nil, nil
}
diff --git a/services/mgmt/node/impl/dispatcher.go b/services/mgmt/node/impl/dispatcher.go
index 684ce97..4d1865e 100644
--- a/services/mgmt/node/impl/dispatcher.go
+++ b/services/mgmt/node/impl/dispatcher.go
@@ -221,7 +221,7 @@
// DISPATCHER INTERFACE IMPLEMENTATION
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
components := strings.Split(suffix, "/")
for i := 0; i < len(components); i++ {
if len(components[i]) == 0 {
diff --git a/services/mgmt/node/impl/proxy_invoker_test.go b/services/mgmt/node/impl/proxy_invoker_test.go
index dd87323..4846998 100644
--- a/services/mgmt/node/impl/proxy_invoker_test.go
+++ b/services/mgmt/node/impl/proxy_invoker_test.go
@@ -5,7 +5,6 @@
"sort"
"testing"
- "veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
@@ -101,6 +100,6 @@
sigStub signatureStub
}
-func (d *proxyDispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *proxyDispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
return &proxyInvoker{naming.Join(d.remote, suffix), d.label, d.sigStub}, nil, nil
}
diff --git a/services/mgmt/pprof/client/proxy_test.go b/services/mgmt/pprof/client/proxy_test.go
index 9c5f251..a563d9f 100644
--- a/services/mgmt/pprof/client/proxy_test.go
+++ b/services/mgmt/pprof/client/proxy_test.go
@@ -20,7 +20,7 @@
invoker ipc.Invoker
}
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
return d.invoker, nil, nil
}
diff --git a/services/mgmt/profile/impl/dispatcher.go b/services/mgmt/profile/impl/dispatcher.go
index 819688b..075fcdc 100644
--- a/services/mgmt/profile/impl/dispatcher.go
+++ b/services/mgmt/profile/impl/dispatcher.go
@@ -29,7 +29,7 @@
// DISPATCHER INTERFACE IMPLEMENTATION
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
invoker := ipc.ReflectInvoker(repository.NewServerProfile(NewInvoker(d.store, d.storeRoot, suffix)))
return invoker, d.auth, nil
}
diff --git a/services/mgmt/root/impl/dispatcher.go b/services/mgmt/root/impl/dispatcher.go
index a0058be..6cf5ee6 100644
--- a/services/mgmt/root/impl/dispatcher.go
+++ b/services/mgmt/root/impl/dispatcher.go
@@ -20,6 +20,6 @@
// DISPATCHER INTERFACE IMPLEMENTATION
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
return ipc.ReflectInvoker(root.NewServerRoot(d.state)), nil, nil
}
diff --git a/services/mgmt/stats/impl/stats_invoker_test.go b/services/mgmt/stats/impl/stats_invoker_test.go
index 2b5b4ae..d15c915 100644
--- a/services/mgmt/stats/impl/stats_invoker_test.go
+++ b/services/mgmt/stats/impl/stats_invoker_test.go
@@ -6,7 +6,6 @@
"testing"
"time"
- "veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
@@ -23,7 +22,7 @@
type statsDispatcher struct {
}
-func (d *statsDispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *statsDispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
return impl.NewStatsInvoker(suffix, 100*time.Millisecond), nil, nil
}
diff --git a/services/mounttable/lib/collectionserver_test.go b/services/mounttable/lib/collectionserver_test.go
index 55fa7e6..90a0208 100644
--- a/services/mounttable/lib/collectionserver_test.go
+++ b/services/mounttable/lib/collectionserver_test.go
@@ -29,7 +29,7 @@
}
// Lookup implements ipc.Dispatcher.Lookup.
-func (d *collectionDispatcher) Lookup(name, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *collectionDispatcher) Lookup(name, method string) (interface{}, security.Authorizer, error) {
rpcc := &rpcContext{name: name, collectionServer: d.collectionServer}
return ipc.ReflectInvoker(rpcc), d, nil
}
diff --git a/services/mounttable/lib/mounttable.go b/services/mounttable/lib/mounttable.go
index a854b70..a0955a5 100644
--- a/services/mounttable/lib/mounttable.go
+++ b/services/mounttable/lib/mounttable.go
@@ -95,7 +95,7 @@
}
// Lookup implements ipc.Dispatcher.Lookup.
-func (mt *mountTable) Lookup(name, method string) (ipc.Invoker, security.Authorizer, error) {
+func (mt *mountTable) Lookup(name, method string) (interface{}, security.Authorizer, error) {
vlog.VI(2).Infof("*********************Lookup %s", name)
mt.RLock()
defer mt.RUnlock()
diff --git a/services/mounttable/lib/neighborhood.go b/services/mounttable/lib/neighborhood.go
index 5300429..4f7fffa 100644
--- a/services/mounttable/lib/neighborhood.go
+++ b/services/mounttable/lib/neighborhood.go
@@ -123,7 +123,7 @@
}
// Lookup implements ipc.Dispatcher.Lookup.
-func (nh *neighborhood) Lookup(name, method string) (ipc.Invoker, security.Authorizer, error) {
+func (nh *neighborhood) Lookup(name, method string) (interface{}, security.Authorizer, error) {
vlog.VI(1).Infof("*********************LookupServer '%s'\n", name)
elems := strings.Split(name, "/")[nh.nelems:]
if name == "" {
diff --git a/tools/application/impl_test.go b/tools/application/impl_test.go
index b6d5d64..c55a5e9 100644
--- a/tools/application/impl_test.go
+++ b/tools/application/impl_test.go
@@ -68,7 +68,7 @@
return &dispatcher{}
}
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
invoker := ipc.ReflectInvoker(repository.NewServerApplication(&server{suffix: suffix}))
return invoker, nil, nil
}
diff --git a/tools/associate/impl_test.go b/tools/associate/impl_test.go
index 7043fcf..fff2ee5 100644
--- a/tools/associate/impl_test.go
+++ b/tools/associate/impl_test.go
@@ -62,18 +62,18 @@
func (*mockNodeInvoker) IsRunnable(_ ipc.ServerContext, description binary.Description) (bool, error) {
return false, nil
}
-func (*mockNodeInvoker) Reset(call ipc.ServerContext, deadline uint64) error { return nil }
-func (*mockNodeInvoker) Install(ipc.ServerContext, string) (string, error) { return "", nil }
-func (*mockNodeInvoker) Refresh(ipc.ServerContext) error { return nil }
-func (*mockNodeInvoker) Restart(ipc.ServerContext) error { return nil }
-func (*mockNodeInvoker) Resume(ipc.ServerContext) error { return nil }
-func (i *mockNodeInvoker) Revert(call ipc.ServerContext) error { return nil }
-func (*mockNodeInvoker) Start(ipc.ServerContext) ([]string, error) { return []string{}, nil }
-func (*mockNodeInvoker) Stop(ipc.ServerContext, uint32) error { return nil }
-func (*mockNodeInvoker) Suspend(ipc.ServerContext) error { return nil }
-func (*mockNodeInvoker) Uninstall(ipc.ServerContext) error { return nil }
-func (i *mockNodeInvoker) Update(ipc.ServerContext) error { return nil }
-func (*mockNodeInvoker) UpdateTo(ipc.ServerContext, string) error { return nil }
+func (*mockNodeInvoker) Reset(call ipc.ServerContext, deadline uint64) error { return nil }
+func (*mockNodeInvoker) Install(ipc.ServerContext, string) (string, error) { return "", nil }
+func (*mockNodeInvoker) Refresh(ipc.ServerContext) error { return nil }
+func (*mockNodeInvoker) Restart(ipc.ServerContext) error { return nil }
+func (*mockNodeInvoker) Resume(ipc.ServerContext) error { return nil }
+func (i *mockNodeInvoker) Revert(call ipc.ServerContext) error { return nil }
+func (*mockNodeInvoker) Start(ipc.ServerContext) ([]string, error) { return []string{}, nil }
+func (*mockNodeInvoker) Stop(ipc.ServerContext, uint32) error { return nil }
+func (*mockNodeInvoker) Suspend(ipc.ServerContext) error { return nil }
+func (*mockNodeInvoker) Uninstall(ipc.ServerContext) error { return nil }
+func (i *mockNodeInvoker) Update(ipc.ServerContext) error { return nil }
+func (*mockNodeInvoker) UpdateTo(ipc.ServerContext, string) error { return nil }
func (i *mockNodeInvoker) SetACL(ipc.ServerContext, security.ACL, string) error { return nil }
func (i *mockNodeInvoker) GetACL(ipc.ServerContext) (security.ACL, string, error) {
return security.ACL{}, "", nil
@@ -91,7 +91,7 @@
return &dispatcher{tape: tape, t: t}
}
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
invoker := ipc.ReflectInvoker(node.NewServerNode(&mockNodeInvoker{tape: d.tape, t: d.t}))
return invoker, nil, nil
}
diff --git a/tools/binary/impl_test.go b/tools/binary/impl_test.go
index 3de1f9a..a924a93 100644
--- a/tools/binary/impl_test.go
+++ b/tools/binary/impl_test.go
@@ -77,7 +77,7 @@
return &dispatcher{}
}
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
invoker := ipc.ReflectInvoker(repository.NewServerBinary(&server{suffix: suffix}))
return invoker, nil, nil
}
diff --git a/tools/mounttable/impl_test.go b/tools/mounttable/impl_test.go
index 4e23910..9dfe601 100644
--- a/tools/mounttable/impl_test.go
+++ b/tools/mounttable/impl_test.go
@@ -56,7 +56,7 @@
type dispatcher struct {
}
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
invoker := ipc.ReflectInvoker(mounttable.NewServerMountTable(&server{suffix: suffix}))
return invoker, nil, nil
}
diff --git a/tools/profile/impl_test.go b/tools/profile/impl_test.go
index 99f2562..0bfd27e 100644
--- a/tools/profile/impl_test.go
+++ b/tools/profile/impl_test.go
@@ -79,7 +79,7 @@
return &dispatcher{}
}
-func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
+func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
invoker := ipc.ReflectInvoker(repository.NewServerProfile(&server{suffix: suffix}))
return invoker, nil, nil
}