veyron2/ipc: 4 of n. 'Invoker and Signature' rationalisation.
- first CL to remove use of ReflectInvoker from our app code.
Change-Id: Ia2ef1ae14f248fa16c4f798d8fc68136c0e1d017
diff --git a/lib/modules/core/echo.go b/lib/modules/core/echo.go
index b1b8877..b989ef8 100644
--- a/lib/modules/core/echo.go
+++ b/lib/modules/core/echo.go
@@ -23,7 +23,7 @@
type treeDispatcher struct{ id string }
func (d treeDispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- return ipc.ReflectInvoker(&echoServerObject{d.id, suffix}), nil, nil
+ return &echoServerObject{d.id, suffix}, nil, nil
}
type echoServerObject struct {
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 62475d8..cc17fe7 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -140,7 +140,7 @@
var authorizer security.Authorizer
switch suffix {
case "discharger":
- return ipc.ReflectInvoker(&dischargeServer{}), testServerAuthorizer{}, nil
+ return &dischargeServer{}, testServerAuthorizer{}, nil
case "nilAuth":
authorizer = nil
case "aclAuth":
@@ -152,7 +152,7 @@
default:
authorizer = testServerAuthorizer{}
}
- return ipc.ReflectInvoker(t.server), authorizer, nil
+ return t.server, authorizer, nil
}
type dischargeServer struct{}
@@ -619,7 +619,7 @@
// Implements ipc.Dispatcher
func (s *dischargeImpetusTester) Lookup(_, _ string) (interface{}, security.Authorizer, error) {
- return ipc.ReflectInvoker(s), testServerAuthorizer{}, nil
+ return s, testServerAuthorizer{}, nil
}
// Implements the discharge service: Always fails to issue a discharge, but records the impetus
diff --git a/runtimes/google/naming/namespace/all_test.go b/runtimes/google/naming/namespace/all_test.go
index 83995ad..abaa21e 100644
--- a/runtimes/google/naming/namespace/all_test.go
+++ b/runtimes/google/naming/namespace/all_test.go
@@ -119,7 +119,7 @@
type dispatcher struct{}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- return ipc.ReflectInvoker(&testServer{suffix}), allowEveryoneAuthorizer{}, nil
+ return &testServer{suffix}, allowEveryoneAuthorizer{}, nil
}
func knockKnock(t *testing.T, runtime veyron2.Runtime, name string) {
diff --git a/services/identity/identityd/main.go b/services/identity/identityd/main.go
index 84a2bac..3372b0b 100644
--- a/services/identity/identityd/main.go
+++ b/services/identity/identityd/main.go
@@ -139,15 +139,15 @@
return names
}
-// newDispatcher returns a dispatcher for both the blessing and the discharging service.
-// their suffix. ReflectInvoker is used to invoke methods.
+// newDispatcher returns a dispatcher for both the blessing and the
+// discharging service.
func newDispatcher(googleParams blesser.GoogleParams, macaroonKey []byte) ipc.Dispatcher {
- d := dispatcher(map[string]ipc.Invoker{
- macaroonService: ipc.ReflectInvoker(blesser.NewMacaroonBlesserServer(macaroonKey)),
- dischargerService: ipc.ReflectInvoker(services.DischargerServer(discharger.NewDischarger())),
+ d := dispatcher(map[string]interface{}{
+ macaroonService: blesser.NewMacaroonBlesserServer(macaroonKey),
+ dischargerService: services.DischargerServer(discharger.NewDischarger()),
})
if len(*googleConfigChrome) > 0 || len(*googleConfigAndroid) > 0 {
- d[googleService] = ipc.ReflectInvoker(blesser.NewGoogleOAuthBlesserServer(googleParams))
+ d[googleService] = blesser.NewGoogleOAuthBlesserServer(googleParams)
}
return d
}
@@ -156,7 +156,7 @@
func (allowEveryoneAuthorizer) Authorize(security.Context) error { return nil }
-type dispatcher map[string]ipc.Invoker
+type dispatcher map[string]interface{}
func (d dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
if invoker := d[suffix]; invoker != nil {
diff --git a/services/mgmt/application/impl/dispatcher.go b/services/mgmt/application/impl/dispatcher.go
index a130f16..f1892e7 100644
--- a/services/mgmt/application/impl/dispatcher.go
+++ b/services/mgmt/application/impl/dispatcher.go
@@ -30,6 +30,5 @@
// DISPATCHER INTERFACE IMPLEMENTATION
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.ApplicationServer(NewInvoker(d.store, d.storeRoot, suffix)))
- return invoker, d.auth, nil
+ return repository.ApplicationServer(NewInvoker(d.store, d.storeRoot, suffix)), d.auth, nil
}
diff --git a/services/mgmt/binary/impl/dispatcher.go b/services/mgmt/binary/impl/dispatcher.go
index e9196e3..166173a 100644
--- a/services/mgmt/binary/impl/dispatcher.go
+++ b/services/mgmt/binary/impl/dispatcher.go
@@ -28,6 +28,5 @@
// DISPATCHER INTERFACE IMPLEMENTATION
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.BinaryServer(newInvoker(d.state, suffix)))
- return invoker, d.auth, nil
+ return repository.BinaryServer(newInvoker(d.state, suffix)), d.auth, nil
}
diff --git a/services/mgmt/debug/dispatcher.go b/services/mgmt/debug/dispatcher.go
index 0c855eb..c4ece25 100644
--- a/services/mgmt/debug/dispatcher.go
+++ b/services/mgmt/debug/dispatcher.go
@@ -41,7 +41,7 @@
suffix = strings.TrimLeft(suffix, "/")
if method == "Signature" {
- return NewSignatureInvoker(suffix), d.auth, nil
+ return NewSignatureObject(suffix), d.auth, nil
}
if suffix == "" {
return ipc.VChildrenGlobberInvoker("logs", "pprof", "stats", "vtrace"), d.auth, nil
@@ -54,11 +54,11 @@
}
switch parts[0] {
case "logs":
- return logreaderimpl.NewLogFileInvoker(d.logsDir, suffix), d.auth, nil
+ return logreaderimpl.NewLogFileServer(d.logsDir, suffix), d.auth, nil
case "pprof":
- return pprofimpl.NewInvoker(), d.auth, nil
+ return pprofimpl.NewServer(), d.auth, nil
case "stats":
- return statsimpl.NewStatsInvoker(suffix, 10*time.Second), d.auth, nil
+ return statsimpl.NewStatsServer(suffix, 10*time.Second), d.auth, nil
case "vtrace":
return vtraceimpl.NewVtraceService(d.store), d.auth, nil
}
diff --git a/services/mgmt/debug/signature.go b/services/mgmt/debug/signature.go
index 99e99d6..9b96741 100644
--- a/services/mgmt/debug/signature.go
+++ b/services/mgmt/debug/signature.go
@@ -10,9 +10,9 @@
suffix string
}
-// NewSignatureInvoker is the invoker factory.
-func NewSignatureInvoker(suffix string) ipc.Invoker {
- return ipc.ReflectInvoker(&signatureInvoker{suffix})
+// NewSignatureObject is the signature object factory.
+func NewSignatureObject(suffix string) interface{} {
+ return &signatureInvoker{suffix}
}
// TODO(rthellend): This is a temporary hack until https://code.google.com/p/envyor/issues/detail?id=285 is resolved.
diff --git a/services/mgmt/logreader/impl/logfile_invoker.go b/services/mgmt/logreader/impl/logfile_invoker.go
index 8f4f88c..b59c08e 100644
--- a/services/mgmt/logreader/impl/logfile_invoker.go
+++ b/services/mgmt/logreader/impl/logfile_invoker.go
@@ -20,9 +20,9 @@
suffix string
}
-// NewLogFileInvoker is the invoker factory.
-func NewLogFileInvoker(root, suffix string) ipc.Invoker {
- return ipc.ReflectInvoker(&logFileInvoker{filepath.Clean(root), suffix})
+// NewLogFileServer returns a new log file server.
+func NewLogFileServer(root, suffix string) interface{} {
+ return &logFileInvoker{filepath.Clean(root), suffix}
}
// Size returns the size of the log file, in bytes.
diff --git a/services/mgmt/logreader/impl/logfile_invoker_test.go b/services/mgmt/logreader/impl/logfile_invoker_test.go
index 3defb7e..eb0be9c 100644
--- a/services/mgmt/logreader/impl/logfile_invoker_test.go
+++ b/services/mgmt/logreader/impl/logfile_invoker_test.go
@@ -47,7 +47,7 @@
}
func (d *logFileDispatcher) Lookup(suffix, _ string) (interface{}, security.Authorizer, error) {
- return impl.NewLogFileInvoker(d.root, suffix), nil, nil
+ return impl.NewLogFileServer(d.root, suffix), nil, nil
}
func writeAndSync(t *testing.T, w *os.File, s string) {
diff --git a/services/mgmt/node/impl/dispatcher.go b/services/mgmt/node/impl/dispatcher.go
index 679a459..3ebc87c 100644
--- a/services/mgmt/node/impl/dispatcher.go
+++ b/services/mgmt/node/impl/dispatcher.go
@@ -350,7 +350,7 @@
disp: d,
uat: d.uat,
})
- return ipc.ReflectInvoker(receiver), d.auth, nil
+ return receiver, d.auth, nil
case appsSuffix:
// Requests to apps/*/*/*/logs are handled locally by LogFileInvoker.
// Requests to apps/*/*/*/pprof are proxied to the apps' __debug/pprof object.
@@ -365,7 +365,7 @@
case "logs":
logsDir := filepath.Join(appInstanceDir, "logs")
suffix := naming.Join(components[5:]...)
- return logsimpl.NewLogFileInvoker(logsDir, suffix), d.auth, nil
+ return logsimpl.NewLogFileServer(logsDir, suffix), d.auth, nil
case "pprof", "stats":
info, err := loadInstanceInfo(appInstanceDir)
if err != nil {
@@ -404,7 +404,7 @@
if err != nil {
return nil, nil, err
}
- return ipc.ReflectInvoker(receiver), appSpecificAuthorizer, nil
+ return receiver, appSpecificAuthorizer, nil
case configSuffix:
if len(components) != 2 {
return nil, nil, errInvalidSuffix
@@ -420,7 +420,7 @@
// TODO(caprita,rjkroege): We should further refine this, by
// only allowing the app to update state referring to itself
// (and not other apps).
- return ipc.ReflectInvoker(receiver), nil, nil
+ return receiver, nil, nil
default:
return nil, nil, errInvalidSuffix
}
diff --git a/services/mgmt/pprof/client/proxy_test.go b/services/mgmt/pprof/client/proxy_test.go
index 9b9c655..3fa6ace 100644
--- a/services/mgmt/pprof/client/proxy_test.go
+++ b/services/mgmt/pprof/client/proxy_test.go
@@ -6,7 +6,6 @@
"net/http"
"testing"
- "veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
@@ -17,11 +16,11 @@
)
type dispatcher struct {
- invoker ipc.Invoker
+ server interface{}
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- return d.invoker, nil, nil
+ return d.server, nil, nil
}
func TestPProfProxy(t *testing.T) {
@@ -37,7 +36,7 @@
if err != nil {
t.Fatalf("failed to listen: %v", err)
}
- if err := s.ServeDispatcher("", &dispatcher{impl.NewInvoker()}); err != nil {
+ if err := s.ServeDispatcher("", &dispatcher{impl.NewServer()}); err != nil {
t.Fatalf("failed to serve: %v", err)
}
l, err := client.StartProxy(r, naming.JoinAddressName(endpoint.String(), ""))
diff --git a/services/mgmt/pprof/impl/server.go b/services/mgmt/pprof/impl/server.go
index e7f13ff..93ffe95 100644
--- a/services/mgmt/pprof/impl/server.go
+++ b/services/mgmt/pprof/impl/server.go
@@ -11,9 +11,9 @@
"veyron.io/veyron/veyron2/verror"
)
-// NewInvoker returns a new pprof invoker.
-func NewInvoker() ipc.Invoker {
- return ipc.ReflectInvoker(&pprofInvoker{})
+// NewServer returns a new pprof server.
+func NewServer() interface{} {
+ return &pprofInvoker{}
}
type pprofInvoker struct {
diff --git a/services/mgmt/profile/impl/dispatcher.go b/services/mgmt/profile/impl/dispatcher.go
index 9403b0d..ab4dcf2 100644
--- a/services/mgmt/profile/impl/dispatcher.go
+++ b/services/mgmt/profile/impl/dispatcher.go
@@ -30,6 +30,5 @@
// DISPATCHER INTERFACE IMPLEMENTATION
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.ProfileServer(NewInvoker(d.store, d.storeRoot, suffix)))
- return invoker, d.auth, nil
+ return repository.ProfileServer(NewInvoker(d.store, d.storeRoot, suffix)), d.auth, nil
}
diff --git a/services/mgmt/root/impl/dispatcher.go b/services/mgmt/root/impl/dispatcher.go
index 015f739..c112fe8 100644
--- a/services/mgmt/root/impl/dispatcher.go
+++ b/services/mgmt/root/impl/dispatcher.go
@@ -21,5 +21,5 @@
// DISPATCHER INTERFACE IMPLEMENTATION
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- return ipc.ReflectInvoker(root.RootServer(d.state)), nil, nil
+ return root.RootServer(d.state), nil, nil
}
diff --git a/services/mgmt/stats/impl/stats_invoker.go b/services/mgmt/stats/impl/stats_invoker.go
index 915ff22..ed497c5 100644
--- a/services/mgmt/stats/impl/stats_invoker.go
+++ b/services/mgmt/stats/impl/stats_invoker.go
@@ -29,8 +29,8 @@
// NewStatsInvoker returns a new Invoker. The value of watchFreq is used to
// specify the time between WatchGlob updates.
-func NewStatsInvoker(suffix string, watchFreq time.Duration) ipc.Invoker {
- return ipc.ReflectInvoker(&statsInvoker{suffix, watchFreq})
+func NewStatsServer(suffix string, watchFreq time.Duration) interface{} {
+ return &statsInvoker{suffix, watchFreq}
}
// Glob returns the name of all objects that match pattern.
diff --git a/services/mgmt/stats/impl/stats_invoker_test.go b/services/mgmt/stats/impl/stats_invoker_test.go
index 6a5b08d..8967cc3 100644
--- a/services/mgmt/stats/impl/stats_invoker_test.go
+++ b/services/mgmt/stats/impl/stats_invoker_test.go
@@ -23,7 +23,7 @@
}
func (d *statsDispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- return impl.NewStatsInvoker(suffix, 100*time.Millisecond), nil, nil
+ return impl.NewStatsServer(suffix, 100*time.Millisecond), nil, nil
}
func startServer(t *testing.T) (string, func()) {
diff --git a/services/mgmt/vtrace/impl/vtrace_invoker.go b/services/mgmt/vtrace/impl/vtrace_invoker.go
index d9cbe0a..a683b4b 100644
--- a/services/mgmt/vtrace/impl/vtrace_invoker.go
+++ b/services/mgmt/vtrace/impl/vtrace_invoker.go
@@ -31,10 +31,6 @@
return nil
}
-func NewVtraceInvoker(store vtrace.Store) ipc.Invoker {
- return ipc.ReflectInvoker(&vtraceServer{store})
-}
-
func NewVtraceService(store vtrace.Store) interface{} {
return &vtraceServer{store}
}
diff --git a/services/mounttable/lib/collectionserver_test.go b/services/mounttable/lib/collectionserver_test.go
index 3822118..c2a310a 100644
--- a/services/mounttable/lib/collectionserver_test.go
+++ b/services/mounttable/lib/collectionserver_test.go
@@ -32,7 +32,7 @@
// Lookup implements ipc.Dispatcher.Lookup.
func (d *collectionDispatcher) Lookup(name, method string) (interface{}, security.Authorizer, error) {
rpcc := &rpcContext{name: name, collectionServer: d.collectionServer}
- return ipc.ReflectInvoker(rpcc), d, nil
+ return rpcc, d, nil
}
func (collectionDispatcher) Authorize(security.Context) error {
diff --git a/services/mounttable/lib/mounttable.go b/services/mounttable/lib/mounttable.go
index 8aef4b3..906f4ae 100644
--- a/services/mounttable/lib/mounttable.go
+++ b/services/mounttable/lib/mounttable.go
@@ -106,7 +106,7 @@
ms.elems = strings.Split(name, "/")
ms.cleanedElems = strings.Split(strings.TrimLeft(path.Clean(name), "/"), "/")
}
- return ipc.ReflectInvoker(mounttable.MountTableServer(ms)), ms, nil
+ return mounttable.MountTableServer(ms), ms, nil
}
// findNode returns the node for the name path represented by elems. If none exists and create is false, return nil.
diff --git a/services/mounttable/lib/neighborhood.go b/services/mounttable/lib/neighborhood.go
index 0f98b7f..78b3ce1 100644
--- a/services/mounttable/lib/neighborhood.go
+++ b/services/mounttable/lib/neighborhood.go
@@ -17,7 +17,7 @@
verror "veyron.io/veyron/veyron2/verror2"
"veyron.io/veyron/veyron2/vlog"
- "github.com/presotto/go-mdns-sd"
+ mdns "github.com/presotto/go-mdns-sd"
)
const addressPrefix = "address:"
@@ -134,7 +134,7 @@
elems: elems,
nh: nh,
}
- return ipc.ReflectInvoker(mounttable.MountTableServer(ns)), nh, nil
+ return mounttable.MountTableServer(ns), nh, nil
}
func (nh *neighborhood) Authorize(context security.Context) error {
diff --git a/tools/application/impl_test.go b/tools/application/impl_test.go
index b107a50..ffe8c66 100644
--- a/tools/application/impl_test.go
+++ b/tools/application/impl_test.go
@@ -69,8 +69,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.ApplicationServer(&server{suffix: suffix}))
- return invoker, nil, nil
+ return repository.ApplicationServer(&server{suffix: suffix}), nil, nil
}
func startServer(t *testing.T, r veyron2.Runtime) (ipc.Server, naming.Endpoint, error) {
diff --git a/tools/binary/impl_test.go b/tools/binary/impl_test.go
index 0dbd6b0..073e8f3 100644
--- a/tools/binary/impl_test.go
+++ b/tools/binary/impl_test.go
@@ -78,8 +78,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.BinaryServer(&server{suffix: suffix}))
- return invoker, nil, nil
+ return repository.BinaryServer(&server{suffix: suffix}), nil, nil
}
func startServer(t *testing.T, r veyron2.Runtime) (ipc.Server, naming.Endpoint, error) {
diff --git a/tools/mgmt/nodex/impl_test.go b/tools/mgmt/nodex/impl_test.go
index b07c4e9..3100e93 100644
--- a/tools/mgmt/nodex/impl_test.go
+++ b/tools/mgmt/nodex/impl_test.go
@@ -112,8 +112,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(node.NodeServer(&mockNodeInvoker{tape: d.tape, t: d.t}))
- return invoker, nil, nil
+ return node.NodeServer(&mockNodeInvoker{tape: d.tape, t: d.t}), nil, nil
}
func startServer(t *testing.T, r veyron2.Runtime, tape *Tape) (ipc.Server, naming.Endpoint, error) {
diff --git a/tools/mounttable/impl_test.go b/tools/mounttable/impl_test.go
index 0a40376..0565b37 100644
--- a/tools/mounttable/impl_test.go
+++ b/tools/mounttable/impl_test.go
@@ -56,8 +56,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(mounttable.MountTableServer(&server{suffix: suffix}))
- return invoker, nil, nil
+ return mounttable.MountTableServer(&server{suffix: suffix}), nil, nil
}
func startServer(t *testing.T, r veyron2.Runtime) (ipc.Server, naming.Endpoint, error) {
diff --git a/tools/profile/impl_test.go b/tools/profile/impl_test.go
index fde8b26..a739a15 100644
--- a/tools/profile/impl_test.go
+++ b/tools/profile/impl_test.go
@@ -80,8 +80,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.ProfileServer(&server{suffix: suffix}))
- return invoker, nil, nil
+ return repository.ProfileServer(&server{suffix: suffix}), nil, nil
}
func startServer(t *testing.T, r veyron2.Runtime) (ipc.Server, naming.Endpoint, error) {