| // This file was auto-generated by the veyron vdl tool. |
| // Source: node.vdl |
| |
| // Package node contains implementation of managing a node and |
| // applications running on the node. |
| package node |
| |
| import ( |
| "veyron2/services/mgmt/node" |
| |
| // 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 |
| } |
| |
| // Node describes a node manager internally. In addition to the public |
| // Node interface, it implements the config functionality. |
| // Node is the interface the client binds and uses. |
| // Node_ExcludingUniversal is the interface without internal framework-added methods |
| // to enable embedding without method collisions. Not to be used directly by clients. |
| type Node_ExcludingUniversal interface { |
| // Node can be used to manage a node. The idea is that this interace |
| // will be invoked using an object name that identifies the node. |
| node.Node_ExcludingUniversal |
| // Config is an RPC API to the config service. |
| Config_ExcludingUniversal |
| } |
| type Node interface { |
| _gen_ipc.UniversalServiceMethods |
| Node_ExcludingUniversal |
| } |
| |
| // NodeService is the interface the server implements. |
| type NodeService interface { |
| |
| // Node can be used to manage a node. The idea is that this interace |
| // will be invoked using an object name that identifies the node. |
| node.NodeService |
| // Config is an RPC API to the config service. |
| ConfigService |
| } |
| |
| // BindNode returns the client stub implementing the Node |
| // interface. |
| // |
| // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| // global Runtime is used. |
| func BindNode(name string, opts ..._gen_ipc.BindOpt) (Node, 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 := &clientStubNode{client: client, name: name} |
| stub.Node_ExcludingUniversal, _ = node.BindNode(name, client) |
| stub.Config_ExcludingUniversal, _ = BindConfig(name, client) |
| |
| return stub, nil |
| } |
| |
| // NewServerNode creates a new server stub. |
| // |
| // It takes a regular server implementing the NodeService |
| // interface, and returns a new server stub. |
| func NewServerNode(server NodeService) interface{} { |
| return &ServerStubNode{ |
| ServerStubNode: *node.NewServerNode(server).(*node.ServerStubNode), |
| ServerStubConfig: *NewServerConfig(server).(*ServerStubConfig), |
| service: server, |
| } |
| } |
| |
| // clientStubNode implements Node. |
| type clientStubNode struct { |
| node.Node_ExcludingUniversal |
| Config_ExcludingUniversal |
| |
| client _gen_ipc.Client |
| name string |
| } |
| |
| func (__gen_c *clientStubNode) 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 *clientStubNode) 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 *clientStubNode) 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 |
| } |
| |
| // ServerStubNode wraps a server that implements |
| // NodeService and provides an object that satisfies |
| // the requirements of veyron2/ipc.ReflectInvoker. |
| type ServerStubNode struct { |
| node.ServerStubNode |
| ServerStubConfig |
| |
| service NodeService |
| } |
| |
| func (__gen_s *ServerStubNode) 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(). |
| if resp, err := __gen_s.ServerStubNode.GetMethodTags(call, method); resp != nil || err != nil { |
| return resp, err |
| } |
| if resp, err := __gen_s.ServerStubConfig.GetMethodTags(call, method); resp != nil || err != nil { |
| return resp, err |
| } |
| return nil, nil |
| } |
| |
| func (__gen_s *ServerStubNode) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
| result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| |
| result.TypeDefs = []_gen_vdlutil.Any{} |
| var ss _gen_ipc.ServiceSignature |
| var firstAdded int |
| ss, _ = __gen_s.ServerStubNode.Signature(call) |
| firstAdded = len(result.TypeDefs) |
| for k, v := range ss.Methods { |
| for i, _ := range v.InArgs { |
| if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst { |
| v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded) |
| } |
| } |
| for i, _ := range v.OutArgs { |
| if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst { |
| v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded) |
| } |
| } |
| if v.InStream >= _gen_wiretype.TypeIDFirst { |
| v.InStream += _gen_wiretype.TypeID(firstAdded) |
| } |
| if v.OutStream >= _gen_wiretype.TypeIDFirst { |
| v.OutStream += _gen_wiretype.TypeID(firstAdded) |
| } |
| result.Methods[k] = v |
| } |
| //TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication. |
| for _, d := range ss.TypeDefs { |
| switch wt := d.(type) { |
| case _gen_wiretype.SliceType: |
| if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| } |
| d = wt |
| case _gen_wiretype.ArrayType: |
| if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| } |
| d = wt |
| case _gen_wiretype.MapType: |
| if wt.Key >= _gen_wiretype.TypeIDFirst { |
| wt.Key += _gen_wiretype.TypeID(firstAdded) |
| } |
| if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| } |
| d = wt |
| case _gen_wiretype.StructType: |
| for i, fld := range wt.Fields { |
| if fld.Type >= _gen_wiretype.TypeIDFirst { |
| wt.Fields[i].Type += _gen_wiretype.TypeID(firstAdded) |
| } |
| } |
| d = wt |
| // NOTE: other types are missing, but we are upgrading anyways. |
| } |
| result.TypeDefs = append(result.TypeDefs, d) |
| } |
| ss, _ = __gen_s.ServerStubConfig.Signature(call) |
| firstAdded = len(result.TypeDefs) |
| for k, v := range ss.Methods { |
| for i, _ := range v.InArgs { |
| if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst { |
| v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded) |
| } |
| } |
| for i, _ := range v.OutArgs { |
| if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst { |
| v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded) |
| } |
| } |
| if v.InStream >= _gen_wiretype.TypeIDFirst { |
| v.InStream += _gen_wiretype.TypeID(firstAdded) |
| } |
| if v.OutStream >= _gen_wiretype.TypeIDFirst { |
| v.OutStream += _gen_wiretype.TypeID(firstAdded) |
| } |
| result.Methods[k] = v |
| } |
| //TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication. |
| for _, d := range ss.TypeDefs { |
| switch wt := d.(type) { |
| case _gen_wiretype.SliceType: |
| if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| } |
| d = wt |
| case _gen_wiretype.ArrayType: |
| if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| } |
| d = wt |
| case _gen_wiretype.MapType: |
| if wt.Key >= _gen_wiretype.TypeIDFirst { |
| wt.Key += _gen_wiretype.TypeID(firstAdded) |
| } |
| if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| } |
| d = wt |
| case _gen_wiretype.StructType: |
| for i, fld := range wt.Fields { |
| if fld.Type >= _gen_wiretype.TypeIDFirst { |
| wt.Fields[i].Type += _gen_wiretype.TypeID(firstAdded) |
| } |
| } |
| d = wt |
| // NOTE: other types are missing, but we are upgrading anyways. |
| } |
| result.TypeDefs = append(result.TypeDefs, d) |
| } |
| |
| return result, nil |
| } |
| |
| func (__gen_s *ServerStubNode) 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 |
| } |