| // This file was auto-generated by the veyron vdl tool. |
| // Source: servers.vdl |
| |
| package modules |
| |
| import ( |
| // The non-user imports are prefixed with "_gen_" to prevent collisions. |
| _gen_veyron2 "veyron2" |
| _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" |
| ) |
| |
| // Clock is the interface the client binds and uses. |
| // Clock_ExcludingUniversal is the interface without internal framework-added methods |
| // to enable embedding without method collisions. Not to be used directly by clients. |
| type Clock_ExcludingUniversal interface { |
| // Time returns a string of the form "(current time) msg" |
| Time(ctx _gen_context.T, msg string, opts ..._gen_ipc.CallOpt) (reply string, err error) |
| } |
| type Clock interface { |
| _gen_ipc.UniversalServiceMethods |
| Clock_ExcludingUniversal |
| } |
| |
| // ClockService is the interface the server implements. |
| type ClockService interface { |
| |
| // Time returns a string of the form "(current time) msg" |
| Time(context _gen_ipc.ServerContext, msg string) (reply string, err error) |
| } |
| |
| // BindClock returns the client stub implementing the Clock |
| // interface. |
| // |
| // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| // global Runtime is used. |
| func BindClock(name string, opts ..._gen_ipc.BindOpt) (Clock, 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_veyron2.Runtime: |
| client = o.Client() |
| case _gen_ipc.Client: |
| client = o |
| default: |
| return nil, _gen_vdlutil.ErrUnrecognizedOption |
| } |
| default: |
| return nil, _gen_vdlutil.ErrTooManyOptionsToBind |
| } |
| stub := &clientStubClock{client: client, name: name} |
| |
| return stub, nil |
| } |
| |
| // NewServerClock creates a new server stub. |
| // |
| // It takes a regular server implementing the ClockService |
| // interface, and returns a new server stub. |
| func NewServerClock(server ClockService) interface{} { |
| return &ServerStubClock{ |
| service: server, |
| } |
| } |
| |
| // clientStubClock implements Clock. |
| type clientStubClock struct { |
| client _gen_ipc.Client |
| name string |
| } |
| |
| func (__gen_c *clientStubClock) Time(ctx _gen_context.T, msg string, opts ..._gen_ipc.CallOpt) (reply string, err error) { |
| var call _gen_ipc.Call |
| if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Time", []interface{}{msg}, opts...); err != nil { |
| return |
| } |
| if ierr := call.Finish(&reply, &err); ierr != nil { |
| err = ierr |
| } |
| return |
| } |
| |
| func (__gen_c *clientStubClock) 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 *clientStubClock) 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 *clientStubClock) 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 |
| } |
| |
| // ServerStubClock wraps a server that implements |
| // ClockService and provides an object that satisfies |
| // the requirements of veyron2/ipc.ReflectInvoker. |
| type ServerStubClock struct { |
| service ClockService |
| } |
| |
| func (__gen_s *ServerStubClock) 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 "Time": |
| return []interface{}{}, nil |
| default: |
| return nil, nil |
| } |
| } |
| |
| func (__gen_s *ServerStubClock) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
| result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| result.Methods["Time"] = _gen_ipc.MethodSignature{ |
| InArgs: []_gen_ipc.MethodArgument{ |
| {Name: "msg", Type: 3}, |
| }, |
| OutArgs: []_gen_ipc.MethodArgument{ |
| {Name: "", Type: 3}, |
| {Name: "", Type: 65}, |
| }, |
| } |
| |
| result.TypeDefs = []_gen_vdlutil.Any{ |
| _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}} |
| |
| return result, nil |
| } |
| |
| func (__gen_s *ServerStubClock) 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 *ServerStubClock) Time(call _gen_ipc.ServerCall, msg string) (reply string, err error) { |
| reply, err = __gen_s.service.Time(call, msg) |
| return |
| } |
| |
| // Echo is the interface the client binds and uses. |
| // Echo_ExcludingUniversal is the interface without internal framework-added methods |
| // to enable embedding without method collisions. Not to be used directly by clients. |
| type Echo_ExcludingUniversal interface { |
| // Echo simply returns its argument as its result |
| Echo(ctx _gen_context.T, msg string, opts ..._gen_ipc.CallOpt) (reply string, err error) |
| } |
| type Echo interface { |
| _gen_ipc.UniversalServiceMethods |
| Echo_ExcludingUniversal |
| } |
| |
| // EchoService is the interface the server implements. |
| type EchoService interface { |
| |
| // Echo simply returns its argument as its result |
| Echo(context _gen_ipc.ServerContext, msg string) (reply string, err error) |
| } |
| |
| // BindEcho returns the client stub implementing the Echo |
| // interface. |
| // |
| // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| // global Runtime is used. |
| func BindEcho(name string, opts ..._gen_ipc.BindOpt) (Echo, 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_veyron2.Runtime: |
| client = o.Client() |
| case _gen_ipc.Client: |
| client = o |
| default: |
| return nil, _gen_vdlutil.ErrUnrecognizedOption |
| } |
| default: |
| return nil, _gen_vdlutil.ErrTooManyOptionsToBind |
| } |
| stub := &clientStubEcho{client: client, name: name} |
| |
| return stub, nil |
| } |
| |
| // NewServerEcho creates a new server stub. |
| // |
| // It takes a regular server implementing the EchoService |
| // interface, and returns a new server stub. |
| func NewServerEcho(server EchoService) interface{} { |
| return &ServerStubEcho{ |
| service: server, |
| } |
| } |
| |
| // clientStubEcho implements Echo. |
| type clientStubEcho struct { |
| client _gen_ipc.Client |
| name string |
| } |
| |
| func (__gen_c *clientStubEcho) Echo(ctx _gen_context.T, msg string, opts ..._gen_ipc.CallOpt) (reply string, err error) { |
| var call _gen_ipc.Call |
| if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Echo", []interface{}{msg}, opts...); err != nil { |
| return |
| } |
| if ierr := call.Finish(&reply, &err); ierr != nil { |
| err = ierr |
| } |
| return |
| } |
| |
| func (__gen_c *clientStubEcho) 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 *clientStubEcho) 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 *clientStubEcho) 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 |
| } |
| |
| // ServerStubEcho wraps a server that implements |
| // EchoService and provides an object that satisfies |
| // the requirements of veyron2/ipc.ReflectInvoker. |
| type ServerStubEcho struct { |
| service EchoService |
| } |
| |
| func (__gen_s *ServerStubEcho) 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 "Echo": |
| return []interface{}{}, nil |
| default: |
| return nil, nil |
| } |
| } |
| |
| func (__gen_s *ServerStubEcho) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
| result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| result.Methods["Echo"] = _gen_ipc.MethodSignature{ |
| InArgs: []_gen_ipc.MethodArgument{ |
| {Name: "msg", Type: 3}, |
| }, |
| OutArgs: []_gen_ipc.MethodArgument{ |
| {Name: "", Type: 3}, |
| {Name: "", Type: 65}, |
| }, |
| } |
| |
| result.TypeDefs = []_gen_vdlutil.Any{ |
| _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}} |
| |
| return result, nil |
| } |
| |
| func (__gen_s *ServerStubEcho) 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 *ServerStubEcho) Echo(call _gen_ipc.ServerCall, msg string) (reply string, err error) { |
| reply, err = __gen_s.service.Echo(call, msg) |
| return |
| } |