blob: 35862ff9f5e1af5998f8c3ab09476fd5964b69d0 [file] [log] [blame]
Ryan Brownfed691e2014-09-15 13:09:40 -07001// This file was auto-generated by the veyron vdl tool.
2// Source: wire.vdl
3
4package main
5
6import (
7 // The non-user imports are prefixed with "_gen_" to prevent collisions.
Jiri Simsa519c5072014-09-17 21:37:57 -07008 _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 Brownfed691e2014-09-15 13:09:40 -070014)
15
Jing Jin896d7762014-11-03 11:18:52 -080016// 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 Ashcrafte027b5c2014-09-16 14:20:20 -070019const _ = _gen_wiretype.TypeIDInvalid
20
Ryan Brownf6b92272014-09-16 13:24:28 -070021// Simple service used in the agent tests.
Ryan Brownfed691e2014-09-15 13:09:40 -070022// 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.
25type PingPong_ExcludingUniversal interface {
26 Ping(ctx _gen_context.T, message string, opts ..._gen_ipc.CallOpt) (reply string, err error)
27}
28type PingPong interface {
29 _gen_ipc.UniversalServiceMethods
30 PingPong_ExcludingUniversal
31}
32
33// PingPongService is the interface the server implements.
34type 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.
43func BindPingPong(name string, opts ..._gen_ipc.BindOpt) (PingPong, error) {
44 var client _gen_ipc.Client
45 switch len(opts) {
46 case 0:
Ken Ashcrafte027b5c2014-09-16 14:20:20 -070047 // Do nothing.
Ryan Brownfed691e2014-09-15 13:09:40 -070048 case 1:
Ken Ashcrafte027b5c2014-09-16 14:20:20 -070049 if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
50 client = clientOpt
51 } else {
Ryan Brownfed691e2014-09-15 13:09:40 -070052 return nil, _gen_vdlutil.ErrUnrecognizedOption
53 }
54 default:
55 return nil, _gen_vdlutil.ErrTooManyOptionsToBind
56 }
Ken Ashcrafte027b5c2014-09-16 14:20:20 -070057 stub := &clientStubPingPong{defaultClient: client, name: name}
Ryan Brownfed691e2014-09-15 13:09:40 -070058
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.
66func NewServerPingPong(server PingPongService) interface{} {
Robin Thellend94bc4642014-11-05 18:05:08 -080067 stub := &ServerStubPingPong{
Ryan Brownfed691e2014-09-15 13:09:40 -070068 service: server,
69 }
Robin Thellend94bc4642014-11-05 18:05:08 -080070 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 Brownfed691e2014-09-15 13:09:40 -070088}
89
90// clientStubPingPong implements PingPong.
91type clientStubPingPong struct {
Ken Ashcrafte027b5c2014-09-16 14:20:20 -070092 defaultClient _gen_ipc.Client
93 name string
94}
95
96func (__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 Brownfed691e2014-09-15 13:09:40 -0700101}
102
103func (__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 Ashcrafte027b5c2014-09-16 14:20:20 -0700105 if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Ping", []interface{}{message}, opts...); err != nil {
Ryan Brownfed691e2014-09-15 13:09:40 -0700106 return
107 }
108 if ierr := call.Finish(&reply, &err); ierr != nil {
109 err = ierr
110 }
111 return
112}
113
114func (__gen_c *clientStubPingPong) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
115 var call _gen_ipc.Call
Ken Ashcrafte027b5c2014-09-16 14:20:20 -0700116 if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
Ryan Brownfed691e2014-09-15 13:09:40 -0700117 return
118 }
119 if ierr := call.Finish(&reply, &err); ierr != nil {
120 err = ierr
121 }
122 return
123}
124
125func (__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 Ashcrafte027b5c2014-09-16 14:20:20 -0700127 if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
Ryan Brownfed691e2014-09-15 13:09:40 -0700128 return
129 }
130 if ierr := call.Finish(&reply, &err); ierr != nil {
131 err = ierr
132 }
133 return
134}
135
136func (__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 Ashcrafte027b5c2014-09-16 14:20:20 -0700138 if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
Ryan Brownfed691e2014-09-15 13:09:40 -0700139 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.
150type ServerStubPingPong struct {
151 service PingPongService
Robin Thellend94bc4642014-11-05 18:05:08 -0800152 gs *_gen_ipc.GlobState
Ryan Brownfed691e2014-09-15 13:09:40 -0700153}
154
155func (__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
167func (__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
185func (__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 Thellend94bc4642014-11-05 18:05:08 -0800203func (__gen_s *ServerStubPingPong) VGlob() *_gen_ipc.GlobState {
204 return __gen_s.gs
205}
206
Ryan Brownfed691e2014-09-15 13:09:40 -0700207func (__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}