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/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}
 }