Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 1 | // This file was auto-generated by the veyron vdl tool. |
| 2 | // Source: wire.vdl |
| 3 | |
| 4 | package main |
| 5 | |
| 6 | import ( |
| 7 | // The non-user imports are prefixed with "_gen_" to prevent collisions. |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 8 | _gen_veyron2 "veyron.io/veyron/veyron2" |
| 9 | _gen_context "veyron.io/veyron/veyron2/context" |
| 10 | _gen_ipc "veyron.io/veyron/veyron2/ipc" |
| 11 | _gen_naming "veyron.io/veyron/veyron2/naming" |
| 12 | _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil" |
| 13 | _gen_wiretype "veyron.io/veyron/veyron2/wiretype" |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 14 | ) |
| 15 | |
Jing Jin | 896d776 | 2014-11-03 11:18:52 -0800 | [diff] [blame] | 16 | // TODO(toddw): Remove this line once the new signature support is done. |
| 17 | // It corrects a bug where _gen_wiretype is unused in VDL pacakges where only |
| 18 | // bootstrap types are used on interfaces. |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 19 | const _ = _gen_wiretype.TypeIDInvalid |
| 20 | |
Ryan Brown | f6b9227 | 2014-09-16 13:24:28 -0700 | [diff] [blame] | 21 | // Simple service used in the agent tests. |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 22 | // PingPong is the interface the client binds and uses. |
| 23 | // PingPong_ExcludingUniversal is the interface without internal framework-added methods |
| 24 | // to enable embedding without method collisions. Not to be used directly by clients. |
| 25 | type PingPong_ExcludingUniversal interface { |
| 26 | Ping(ctx _gen_context.T, message string, opts ..._gen_ipc.CallOpt) (reply string, err error) |
| 27 | } |
| 28 | type PingPong interface { |
| 29 | _gen_ipc.UniversalServiceMethods |
| 30 | PingPong_ExcludingUniversal |
| 31 | } |
| 32 | |
| 33 | // PingPongService is the interface the server implements. |
| 34 | type PingPongService interface { |
| 35 | Ping(context _gen_ipc.ServerContext, message string) (reply string, err error) |
| 36 | } |
| 37 | |
| 38 | // BindPingPong returns the client stub implementing the PingPong |
| 39 | // interface. |
| 40 | // |
| 41 | // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| 42 | // global Runtime is used. |
| 43 | func BindPingPong(name string, opts ..._gen_ipc.BindOpt) (PingPong, error) { |
| 44 | var client _gen_ipc.Client |
| 45 | switch len(opts) { |
| 46 | case 0: |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 47 | // Do nothing. |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 48 | case 1: |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 49 | if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok { |
| 50 | client = clientOpt |
| 51 | } else { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 52 | return nil, _gen_vdlutil.ErrUnrecognizedOption |
| 53 | } |
| 54 | default: |
| 55 | return nil, _gen_vdlutil.ErrTooManyOptionsToBind |
| 56 | } |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 57 | stub := &clientStubPingPong{defaultClient: client, name: name} |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 58 | |
| 59 | return stub, nil |
| 60 | } |
| 61 | |
| 62 | // NewServerPingPong creates a new server stub. |
| 63 | // |
| 64 | // It takes a regular server implementing the PingPongService |
| 65 | // interface, and returns a new server stub. |
| 66 | func NewServerPingPong(server PingPongService) interface{} { |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame^] | 67 | stub := &ServerStubPingPong{ |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 68 | service: server, |
| 69 | } |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame^] | 70 | var gs _gen_ipc.GlobState |
| 71 | var self interface{} = stub |
| 72 | // VAllGlobber is implemented by the server object, which is wrapped in |
| 73 | // a VDL generated server stub. |
| 74 | if x, ok := self.(_gen_ipc.VAllGlobber); ok { |
| 75 | gs.VAllGlobber = x |
| 76 | } |
| 77 | // VAllGlobber is implemented by the server object without using a VDL |
| 78 | // generated stub. |
| 79 | if x, ok := server.(_gen_ipc.VAllGlobber); ok { |
| 80 | gs.VAllGlobber = x |
| 81 | } |
| 82 | // VChildrenGlobber is implemented in the server object. |
| 83 | if x, ok := server.(_gen_ipc.VChildrenGlobber); ok { |
| 84 | gs.VChildrenGlobber = x |
| 85 | } |
| 86 | stub.gs = &gs |
| 87 | return stub |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | // clientStubPingPong implements PingPong. |
| 91 | type clientStubPingPong struct { |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 92 | defaultClient _gen_ipc.Client |
| 93 | name string |
| 94 | } |
| 95 | |
| 96 | func (__gen_c *clientStubPingPong) client(ctx _gen_context.T) _gen_ipc.Client { |
| 97 | if __gen_c.defaultClient != nil { |
| 98 | return __gen_c.defaultClient |
| 99 | } |
| 100 | return _gen_veyron2.RuntimeFromContext(ctx).Client() |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | func (__gen_c *clientStubPingPong) Ping(ctx _gen_context.T, message string, opts ..._gen_ipc.CallOpt) (reply string, err error) { |
| 104 | var call _gen_ipc.Call |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 105 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Ping", []interface{}{message}, opts...); err != nil { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 106 | return |
| 107 | } |
| 108 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 109 | err = ierr |
| 110 | } |
| 111 | return |
| 112 | } |
| 113 | |
| 114 | func (__gen_c *clientStubPingPong) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) { |
| 115 | var call _gen_ipc.Call |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 116 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 117 | return |
| 118 | } |
| 119 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 120 | err = ierr |
| 121 | } |
| 122 | return |
| 123 | } |
| 124 | |
| 125 | func (__gen_c *clientStubPingPong) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) { |
| 126 | var call _gen_ipc.Call |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 127 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 128 | return |
| 129 | } |
| 130 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 131 | err = ierr |
| 132 | } |
| 133 | return |
| 134 | } |
| 135 | |
| 136 | func (__gen_c *clientStubPingPong) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) { |
| 137 | var call _gen_ipc.Call |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 138 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 139 | return |
| 140 | } |
| 141 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 142 | err = ierr |
| 143 | } |
| 144 | return |
| 145 | } |
| 146 | |
| 147 | // ServerStubPingPong wraps a server that implements |
| 148 | // PingPongService and provides an object that satisfies |
| 149 | // the requirements of veyron2/ipc.ReflectInvoker. |
| 150 | type ServerStubPingPong struct { |
| 151 | service PingPongService |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame^] | 152 | gs *_gen_ipc.GlobState |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | func (__gen_s *ServerStubPingPong) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) { |
| 156 | // TODO(bprosnitz) GetMethodTags() will be replaces with Signature(). |
| 157 | // Note: This exhibits some weird behavior like returning a nil error if the method isn't found. |
| 158 | // This will change when it is replaced with Signature(). |
| 159 | switch method { |
| 160 | case "Ping": |
| 161 | return []interface{}{}, nil |
| 162 | default: |
| 163 | return nil, nil |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | func (__gen_s *ServerStubPingPong) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
| 168 | result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| 169 | result.Methods["Ping"] = _gen_ipc.MethodSignature{ |
| 170 | InArgs: []_gen_ipc.MethodArgument{ |
| 171 | {Name: "message", Type: 3}, |
| 172 | }, |
| 173 | OutArgs: []_gen_ipc.MethodArgument{ |
| 174 | {Name: "", Type: 3}, |
| 175 | {Name: "", Type: 65}, |
| 176 | }, |
| 177 | } |
| 178 | |
| 179 | result.TypeDefs = []_gen_vdlutil.Any{ |
| 180 | _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}} |
| 181 | |
| 182 | return result, nil |
| 183 | } |
| 184 | |
| 185 | func (__gen_s *ServerStubPingPong) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) { |
| 186 | if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok { |
| 187 | return unresolver.UnresolveStep(call) |
| 188 | } |
| 189 | if call.Server() == nil { |
| 190 | return |
| 191 | } |
| 192 | var published []string |
| 193 | if published, err = call.Server().Published(); err != nil || published == nil { |
| 194 | return |
| 195 | } |
| 196 | reply = make([]string, len(published)) |
| 197 | for i, p := range published { |
| 198 | reply[i] = _gen_naming.Join(p, call.Name()) |
| 199 | } |
| 200 | return |
| 201 | } |
| 202 | |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame^] | 203 | func (__gen_s *ServerStubPingPong) VGlob() *_gen_ipc.GlobState { |
| 204 | return __gen_s.gs |
| 205 | } |
| 206 | |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 207 | func (__gen_s *ServerStubPingPong) Ping(call _gen_ipc.ServerCall, message string) (reply string, err error) { |
| 208 | reply, err = __gen_s.service.Ping(call, message) |
| 209 | return |
| 210 | } |