veyron/services/mgmt/impl: code refactoring to split up invoker.go

Split up the RPC method implementations from invoker.go into node_invoker.go,
app_invoker.go, and config_invoker.go, with three separate invoker types. Also
split up internalState accordingly.

Move methods shared by more than one invoker into util.go.

Remove vlog at the beginning of each method. It's verbose, and we can do this
type of logging better in the ipc framework.

Remove counter.go (unused).

Get rid of the internal Node vdl interface, and instead keep Config separate,
which is simpler.

Change-Id: Ia990c7a3098faf3722346ce06023d5a2877362a9
diff --git a/services/mgmt/node/config.vdl.go b/services/mgmt/node/config.vdl.go
new file mode 100644
index 0000000..536330a
--- /dev/null
+++ b/services/mgmt/node/config.vdl.go
@@ -0,0 +1,183 @@
+// This file was auto-generated by the veyron vdl tool.
+// Source: config.vdl
+
+package node
+
+import (
+	// The non-user imports are prefixed with "_gen_" to prevent collisions.
+	_gen_context "veyron2/context"
+	_gen_ipc "veyron2/ipc"
+	_gen_naming "veyron2/naming"
+	_gen_rt "veyron2/rt"
+	_gen_vdlutil "veyron2/vdl/vdlutil"
+	_gen_wiretype "veyron2/wiretype"
+)
+
+// TODO(bprosnitz) Remove this line once signatures are updated to use typevals.
+// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only bootstrap types are used on interfaces.
+const _ = _gen_wiretype.TypeIDInvalid
+
+// Config is an RPC API to the config service.
+// Config is the interface the client binds and uses.
+// Config_ExcludingUniversal is the interface without internal framework-added methods
+// to enable embedding without method collisions.  Not to be used directly by clients.
+type Config_ExcludingUniversal interface {
+	// Set sets the value for key.
+	Set(ctx _gen_context.T, key string, value string, opts ..._gen_ipc.CallOpt) (err error)
+}
+type Config interface {
+	_gen_ipc.UniversalServiceMethods
+	Config_ExcludingUniversal
+}
+
+// ConfigService is the interface the server implements.
+type ConfigService interface {
+
+	// Set sets the value for key.
+	Set(context _gen_ipc.ServerContext, key string, value string) (err error)
+}
+
+// BindConfig returns the client stub implementing the Config
+// interface.
+//
+// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
+// global Runtime is used.
+func BindConfig(name string, opts ..._gen_ipc.BindOpt) (Config, error) {
+	var client _gen_ipc.Client
+	switch len(opts) {
+	case 0:
+		client = _gen_rt.R().Client()
+	case 1:
+		switch o := opts[0].(type) {
+		case _gen_ipc.Client:
+			client = o
+		default:
+			return nil, _gen_vdlutil.ErrUnrecognizedOption
+		}
+	default:
+		return nil, _gen_vdlutil.ErrTooManyOptionsToBind
+	}
+	stub := &clientStubConfig{client: client, name: name}
+
+	return stub, nil
+}
+
+// NewServerConfig creates a new server stub.
+//
+// It takes a regular server implementing the ConfigService
+// interface, and returns a new server stub.
+func NewServerConfig(server ConfigService) interface{} {
+	return &ServerStubConfig{
+		service: server,
+	}
+}
+
+// clientStubConfig implements Config.
+type clientStubConfig struct {
+	client _gen_ipc.Client
+	name   string
+}
+
+func (__gen_c *clientStubConfig) Set(ctx _gen_context.T, key string, value string, opts ..._gen_ipc.CallOpt) (err error) {
+	var call _gen_ipc.Call
+	if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Set", []interface{}{key, value}, opts...); err != nil {
+		return
+	}
+	if ierr := call.Finish(&err); ierr != nil {
+		err = ierr
+	}
+	return
+}
+
+func (__gen_c *clientStubConfig) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
+	var call _gen_ipc.Call
+	if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
+		return
+	}
+	if ierr := call.Finish(&reply, &err); ierr != nil {
+		err = ierr
+	}
+	return
+}
+
+func (__gen_c *clientStubConfig) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
+	var call _gen_ipc.Call
+	if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
+		return
+	}
+	if ierr := call.Finish(&reply, &err); ierr != nil {
+		err = ierr
+	}
+	return
+}
+
+func (__gen_c *clientStubConfig) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
+	var call _gen_ipc.Call
+	if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+		return
+	}
+	if ierr := call.Finish(&reply, &err); ierr != nil {
+		err = ierr
+	}
+	return
+}
+
+// ServerStubConfig wraps a server that implements
+// ConfigService and provides an object that satisfies
+// the requirements of veyron2/ipc.ReflectInvoker.
+type ServerStubConfig struct {
+	service ConfigService
+}
+
+func (__gen_s *ServerStubConfig) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
+	// TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
+	// Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
+	// This will change when it is replaced with Signature().
+	switch method {
+	case "Set":
+		return []interface{}{}, nil
+	default:
+		return nil, nil
+	}
+}
+
+func (__gen_s *ServerStubConfig) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
+	result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
+	result.Methods["Set"] = _gen_ipc.MethodSignature{
+		InArgs: []_gen_ipc.MethodArgument{
+			{Name: "key", Type: 3},
+			{Name: "value", Type: 3},
+		},
+		OutArgs: []_gen_ipc.MethodArgument{
+			{Name: "", Type: 65},
+		},
+	}
+
+	result.TypeDefs = []_gen_vdlutil.Any{
+		_gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+
+	return result, nil
+}
+
+func (__gen_s *ServerStubConfig) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
+	if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
+		return unresolver.UnresolveStep(call)
+	}
+	if call.Server() == nil {
+		return
+	}
+	var published []string
+	if published, err = call.Server().Published(); err != nil || published == nil {
+		return
+	}
+	reply = make([]string, len(published))
+	for i, p := range published {
+		reply[i] = _gen_naming.Join(p, call.Name())
+	}
+	return
+}
+
+func (__gen_s *ServerStubConfig) Set(call _gen_ipc.ServerCall, key string, value string) (err error) {
+	err = __gen_s.service.Set(call, key, value)
+	return
+}