| // This file was auto-generated by the veyron vdl tool. |
| // Source: service.vdl |
| |
| package server |
| |
| import ( |
| "veyron2/services/store" |
| |
| // 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_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 |
| |
| // Named 'storeThing' instead of 'thing' so that the struct in thing.go can be |
| // named 'thing'. |
| // storeThing is the interface the client binds and uses. |
| // storeThing_ExcludingUniversal is the interface without internal framework-added methods |
| // to enable embedding without method collisions. Not to be used directly by clients. |
| type storeThing_ExcludingUniversal interface { |
| store.DirSpecific_ExcludingUniversal |
| store.ObjectSpecific_ExcludingUniversal |
| store.DirOrObject_ExcludingUniversal |
| store.Transaction_ExcludingUniversal |
| } |
| type storeThing interface { |
| _gen_ipc.UniversalServiceMethods |
| storeThing_ExcludingUniversal |
| } |
| |
| // storeThingService is the interface the server implements. |
| type storeThingService interface { |
| store.DirSpecificService |
| store.ObjectSpecificService |
| store.DirOrObjectService |
| store.TransactionService |
| } |
| |
| // BindstoreThing returns the client stub implementing the storeThing |
| // interface. |
| // |
| // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| // global Runtime is used. |
| func BindstoreThing(name string, opts ..._gen_ipc.BindOpt) (storeThing, error) { |
| var client _gen_ipc.Client |
| switch len(opts) { |
| case 0: |
| // Do nothing. |
| case 1: |
| if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok { |
| client = clientOpt |
| } else { |
| return nil, _gen_vdlutil.ErrUnrecognizedOption |
| } |
| default: |
| return nil, _gen_vdlutil.ErrTooManyOptionsToBind |
| } |
| stub := &clientStubstoreThing{defaultClient: client, name: name} |
| stub.DirSpecific_ExcludingUniversal, _ = store.BindDirSpecific(name, client) |
| stub.ObjectSpecific_ExcludingUniversal, _ = store.BindObjectSpecific(name, client) |
| stub.DirOrObject_ExcludingUniversal, _ = store.BindDirOrObject(name, client) |
| stub.Transaction_ExcludingUniversal, _ = store.BindTransaction(name, client) |
| |
| return stub, nil |
| } |
| |
| // NewServerstoreThing creates a new server stub. |
| // |
| // It takes a regular server implementing the storeThingService |
| // interface, and returns a new server stub. |
| func NewServerstoreThing(server storeThingService) interface{} { |
| return &ServerStubstoreThing{ |
| ServerStubDirSpecific: *store.NewServerDirSpecific(server).(*store.ServerStubDirSpecific), |
| ServerStubObjectSpecific: *store.NewServerObjectSpecific(server).(*store.ServerStubObjectSpecific), |
| ServerStubDirOrObject: *store.NewServerDirOrObject(server).(*store.ServerStubDirOrObject), |
| ServerStubTransaction: *store.NewServerTransaction(server).(*store.ServerStubTransaction), |
| service: server, |
| } |
| } |
| |
| // clientStubstoreThing implements storeThing. |
| type clientStubstoreThing struct { |
| store.DirSpecific_ExcludingUniversal |
| store.ObjectSpecific_ExcludingUniversal |
| store.DirOrObject_ExcludingUniversal |
| store.Transaction_ExcludingUniversal |
| |
| defaultClient _gen_ipc.Client |
| name string |
| } |
| |
| func (__gen_c *clientStubstoreThing) client(ctx _gen_context.T) _gen_ipc.Client { |
| if __gen_c.defaultClient != nil { |
| return __gen_c.defaultClient |
| } |
| return _gen_veyron2.RuntimeFromContext(ctx).Client() |
| } |
| |
| func (__gen_c *clientStubstoreThing) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) { |
| var call _gen_ipc.Call |
| if call, err = __gen_c.client(ctx).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 *clientStubstoreThing) 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(ctx).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 *clientStubstoreThing) 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(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil { |
| return |
| } |
| if ierr := call.Finish(&reply, &err); ierr != nil { |
| err = ierr |
| } |
| return |
| } |
| |
| // ServerStubstoreThing wraps a server that implements |
| // storeThingService and provides an object that satisfies |
| // the requirements of veyron2/ipc.ReflectInvoker. |
| type ServerStubstoreThing struct { |
| store.ServerStubDirSpecific |
| store.ServerStubObjectSpecific |
| store.ServerStubDirOrObject |
| store.ServerStubTransaction |
| |
| service storeThingService |
| } |
| |
| func (__gen_s *ServerStubstoreThing) 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.ServerStubDirSpecific.GetMethodTags(call, method); resp != nil || err != nil { |
| return resp, err |
| } |
| if resp, err := __gen_s.ServerStubObjectSpecific.GetMethodTags(call, method); resp != nil || err != nil { |
| return resp, err |
| } |
| if resp, err := __gen_s.ServerStubDirOrObject.GetMethodTags(call, method); resp != nil || err != nil { |
| return resp, err |
| } |
| if resp, err := __gen_s.ServerStubTransaction.GetMethodTags(call, method); resp != nil || err != nil { |
| return resp, err |
| } |
| return nil, nil |
| } |
| |
| func (__gen_s *ServerStubstoreThing) 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.ServerStubDirSpecific.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.ServerStubObjectSpecific.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.ServerStubDirOrObject.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.ServerStubTransaction.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 *ServerStubstoreThing) 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 |
| } |