blob: 117bb1e2bad2cd4ed827c510d88ab5954802357f [file] [log] [blame]
Robin Thellendcafaa492014-06-24 13:58:25 -07001// This file was auto-generated by the veyron vdl tool.
2// Source: service.vdl
3
4// package benchmark provides simple tools to measure the performance of the
5// IPC system.
6package benchmarks
7
8import (
Todd Wang702385a2014-11-07 01:54:08 -08009 // The non-user imports are prefixed with "__" to prevent collisions.
10 __io "io"
11 __veyron2 "veyron.io/veyron/veyron2"
12 __context "veyron.io/veyron/veyron2/context"
13 __ipc "veyron.io/veyron/veyron2/ipc"
14 __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
15 __wiretype "veyron.io/veyron/veyron2/wiretype"
Robin Thellendcafaa492014-06-24 13:58:25 -070016)
17
Jing Jin896d7762014-11-03 11:18:52 -080018// TODO(toddw): Remove this line once the new signature support is done.
Todd Wang702385a2014-11-07 01:54:08 -080019// It corrects a bug where __wiretype is unused in VDL pacakges where only
Jing Jin896d7762014-11-03 11:18:52 -080020// bootstrap types are used on interfaces.
Todd Wang702385a2014-11-07 01:54:08 -080021const _ = __wiretype.TypeIDInvalid
Shyam Jayaramanc4aed6e2014-07-22 14:25:06 -070022
Todd Wang702385a2014-11-07 01:54:08 -080023// BenchmarkClientMethods is the client interface
24// containing Benchmark methods.
25type BenchmarkClientMethods interface {
Robin Thellendcafaa492014-06-24 13:58:25 -070026 // Echo returns the payload that it receives.
Todd Wang702385a2014-11-07 01:54:08 -080027 Echo(ctx __context.T, Payload []byte, opts ...__ipc.CallOpt) ([]byte, error)
Robin Thellendcafaa492014-06-24 13:58:25 -070028 // EchoStream returns the payload that it receives via the stream.
Todd Wang702385a2014-11-07 01:54:08 -080029 EchoStream(__context.T, ...__ipc.CallOpt) (BenchmarkEchoStreamCall, error)
Robin Thellendcafaa492014-06-24 13:58:25 -070030}
31
Todd Wang702385a2014-11-07 01:54:08 -080032// BenchmarkClientStub adds universal methods to BenchmarkClientMethods.
33type BenchmarkClientStub interface {
34 BenchmarkClientMethods
35 __ipc.UniversalServiceMethods
Robin Thellendcafaa492014-06-24 13:58:25 -070036}
37
Todd Wang702385a2014-11-07 01:54:08 -080038// BenchmarkClient returns a client stub for Benchmark.
39func BenchmarkClient(name string, opts ...__ipc.BindOpt) BenchmarkClientStub {
40 var client __ipc.Client
41 for _, opt := range opts {
42 if clientOpt, ok := opt.(__ipc.Client); ok {
43 client = clientOpt
44 }
45 }
46 return implBenchmarkClientStub{name, client}
47}
48
49type implBenchmarkClientStub struct {
50 name string
51 client __ipc.Client
52}
53
54func (c implBenchmarkClientStub) c(ctx __context.T) __ipc.Client {
55 if c.client != nil {
56 return c.client
57 }
58 return __veyron2.RuntimeFromContext(ctx).Client()
59}
60
61func (c implBenchmarkClientStub) Echo(ctx __context.T, i0 []byte, opts ...__ipc.CallOpt) (o0 []byte, err error) {
62 var call __ipc.Call
63 if call, err = c.c(ctx).StartCall(ctx, c.name, "Echo", []interface{}{i0}, opts...); err != nil {
64 return
65 }
66 if ierr := call.Finish(&o0, &err); ierr != nil {
67 err = ierr
68 }
69 return
70}
71
72func (c implBenchmarkClientStub) EchoStream(ctx __context.T, opts ...__ipc.CallOpt) (ocall BenchmarkEchoStreamCall, err error) {
73 var call __ipc.Call
74 if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoStream", nil, opts...); err != nil {
75 return
76 }
Todd Wang1fe7cdd2014-11-12 12:51:49 -080077 ocall = &implBenchmarkEchoStreamCall{Call: call}
Todd Wang702385a2014-11-07 01:54:08 -080078 return
79}
80
81func (c implBenchmarkClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
82 var call __ipc.Call
83 if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
84 return
85 }
86 if ierr := call.Finish(&o0, &err); ierr != nil {
87 err = ierr
88 }
89 return
90}
91
Todd Wang702385a2014-11-07 01:54:08 -080092// BenchmarkEchoStreamClientStream is the client stream for Benchmark.EchoStream.
93type BenchmarkEchoStreamClientStream interface {
Todd Wang1fe7cdd2014-11-12 12:51:49 -080094 // RecvStream returns the receiver side of the Benchmark.EchoStream client stream.
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -070095 RecvStream() interface {
Todd Wang702385a2014-11-07 01:54:08 -080096 // Advance stages an item so that it may be retrieved via Value. Returns
97 // true iff there is an item to retrieve. Advance must be called before
98 // Value is called. May block if an item is not available.
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -070099 Advance() bool
Todd Wang702385a2014-11-07 01:54:08 -0800100 // Value returns the item that was staged by Advance. May panic if Advance
101 // returned false or was not called. Never blocks.
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700102 Value() []byte
Todd Wang702385a2014-11-07 01:54:08 -0800103 // Err returns any error encountered by Advance. Never blocks.
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700104 Err() error
105 }
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800106 // SendStream returns the send side of the Benchmark.EchoStream client stream.
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700107 SendStream() interface {
Todd Wang702385a2014-11-07 01:54:08 -0800108 // Send places the item onto the output stream. Returns errors encountered
109 // while sending, or if Send is called after Close or Cancel. Blocks if
110 // there is no buffer space; will unblock when buffer space is available or
111 // after Cancel.
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700112 Send(item []byte) error
Todd Wang702385a2014-11-07 01:54:08 -0800113 // Close indicates to the server that no more items will be sent; server
114 // Recv calls will receive io.EOF after all sent items. This is an optional
115 // call - e.g. a client might call Close if it needs to continue receiving
116 // items from the server after it's done sending. Returns errors
117 // encountered while closing, or if Close is called after Cancel. Like
118 // Send, blocks if there is no buffer space available.
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700119 Close() error
120 }
Todd Wang702385a2014-11-07 01:54:08 -0800121}
Shyam Jayaramanc4aed6e2014-07-22 14:25:06 -0700122
Todd Wang702385a2014-11-07 01:54:08 -0800123// BenchmarkEchoStreamCall represents the call returned from Benchmark.EchoStream.
124type BenchmarkEchoStreamCall interface {
125 BenchmarkEchoStreamClientStream
126 // Finish performs the equivalent of SendStream().Close, then blocks until
127 // the server is done, and returns the positional return values for the call.
128 //
129 // Finish returns immediately if Cancel has been called; depending on the
130 // timing the output could either be an error signaling cancelation, or the
131 // valid positional return values from the server.
Shyam Jayaramanc4aed6e2014-07-22 14:25:06 -0700132 //
133 // Calling Finish is mandatory for releasing stream resources, unless Cancel
Todd Wang702385a2014-11-07 01:54:08 -0800134 // has been called or any of the other methods return an error. Finish should
135 // be called at most once.
136 Finish() error
137 // Cancel cancels the RPC, notifying the server to stop processing. It is
138 // safe to call Cancel concurrently with any of the other stream methods.
Shyam Jayaramanc4aed6e2014-07-22 14:25:06 -0700139 // Calling Cancel after Finish has returned is a no-op.
Robin Thellendcafaa492014-06-24 13:58:25 -0700140 Cancel()
141}
142
Todd Wang702385a2014-11-07 01:54:08 -0800143type implBenchmarkEchoStreamCall struct {
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800144 __ipc.Call
145 valRecv []byte
146 errRecv error
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700147}
148
149func (c *implBenchmarkEchoStreamCall) RecvStream() interface {
150 Advance() bool
151 Value() []byte
152 Err() error
153} {
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800154 return implBenchmarkEchoStreamCallRecv{c}
155}
156
157type implBenchmarkEchoStreamCallRecv struct {
158 c *implBenchmarkEchoStreamCall
159}
160
161func (c implBenchmarkEchoStreamCallRecv) Advance() bool {
162 c.c.errRecv = c.c.Recv(&c.c.valRecv)
163 return c.c.errRecv == nil
164}
165func (c implBenchmarkEchoStreamCallRecv) Value() []byte {
166 return c.c.valRecv
167}
168func (c implBenchmarkEchoStreamCallRecv) Err() error {
169 if c.c.errRecv == __io.EOF {
170 return nil
171 }
172 return c.c.errRecv
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700173}
Todd Wang702385a2014-11-07 01:54:08 -0800174func (c *implBenchmarkEchoStreamCall) SendStream() interface {
175 Send(item []byte) error
176 Close() error
177} {
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800178 return implBenchmarkEchoStreamCallSend{c}
179}
180
181type implBenchmarkEchoStreamCallSend struct {
182 c *implBenchmarkEchoStreamCall
183}
184
185func (c implBenchmarkEchoStreamCallSend) Send(item []byte) error {
186 return c.c.Send(item)
187}
188func (c implBenchmarkEchoStreamCallSend) Close() error {
189 return c.c.CloseSend()
Todd Wang702385a2014-11-07 01:54:08 -0800190}
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700191func (c *implBenchmarkEchoStreamCall) Finish() (err error) {
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800192 if ierr := c.Call.Finish(&err); ierr != nil {
Robin Thellendcafaa492014-06-24 13:58:25 -0700193 err = ierr
194 }
195 return
196}
Robin Thellendcafaa492014-06-24 13:58:25 -0700197
Todd Wang702385a2014-11-07 01:54:08 -0800198// BenchmarkServerMethods is the interface a server writer
199// implements for Benchmark.
200type BenchmarkServerMethods interface {
201 // Echo returns the payload that it receives.
202 Echo(ctx __ipc.ServerContext, Payload []byte) ([]byte, error)
203 // EchoStream returns the payload that it receives via the stream.
204 EchoStream(BenchmarkEchoStreamContext) error
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700205}
206
Todd Wang702385a2014-11-07 01:54:08 -0800207// BenchmarkServerStubMethods is the server interface containing
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800208// Benchmark methods, as expected by ipc.Server.
209// The only difference between this interface and BenchmarkServerMethods
210// is the streaming methods.
Todd Wang702385a2014-11-07 01:54:08 -0800211type BenchmarkServerStubMethods interface {
212 // Echo returns the payload that it receives.
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800213 Echo(ctx __ipc.ServerContext, Payload []byte) ([]byte, error)
Todd Wang702385a2014-11-07 01:54:08 -0800214 // EchoStream returns the payload that it receives via the stream.
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800215 EchoStream(*BenchmarkEchoStreamContextStub) error
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700216}
217
Todd Wang702385a2014-11-07 01:54:08 -0800218// BenchmarkServerStub adds universal methods to BenchmarkServerStubMethods.
219type BenchmarkServerStub interface {
220 BenchmarkServerStubMethods
Todd Wang5739dda2014-11-16 22:44:02 -0800221 // Describe the Benchmark interfaces.
222 Describe__() []__ipc.InterfaceDesc
223 // Signature will be replaced with Describe__.
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800224 Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700225}
226
Todd Wang702385a2014-11-07 01:54:08 -0800227// BenchmarkServer returns a server stub for Benchmark.
228// It converts an implementation of BenchmarkServerMethods into
229// an object that may be used by ipc.Server.
230func BenchmarkServer(impl BenchmarkServerMethods) BenchmarkServerStub {
231 stub := implBenchmarkServerStub{
232 impl: impl,
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700233 }
Todd Wang702385a2014-11-07 01:54:08 -0800234 // Initialize GlobState; always check the stub itself first, to handle the
235 // case where the user has the Glob method defined in their VDL source.
236 if gs := __ipc.NewGlobState(stub); gs != nil {
237 stub.gs = gs
238 } else if gs := __ipc.NewGlobState(impl); gs != nil {
239 stub.gs = gs
Shyam Jayaraman97b9dca2014-07-31 13:30:46 -0700240 }
Robin Thellend94bc4642014-11-05 18:05:08 -0800241 return stub
Robin Thellendcafaa492014-06-24 13:58:25 -0700242}
243
Todd Wang702385a2014-11-07 01:54:08 -0800244type implBenchmarkServerStub struct {
245 impl BenchmarkServerMethods
246 gs *__ipc.GlobState
Matt Rosencrantzbf85d542014-08-22 13:31:14 -0700247}
248
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800249func (s implBenchmarkServerStub) Echo(ctx __ipc.ServerContext, i0 []byte) ([]byte, error) {
250 return s.impl.Echo(ctx, i0)
Robin Thellendcafaa492014-06-24 13:58:25 -0700251}
252
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800253func (s implBenchmarkServerStub) EchoStream(ctx *BenchmarkEchoStreamContextStub) error {
Todd Wang702385a2014-11-07 01:54:08 -0800254 return s.impl.EchoStream(ctx)
Robin Thellendcafaa492014-06-24 13:58:25 -0700255}
256
Robin Thellend39ac3232014-12-02 09:50:41 -0800257func (s implBenchmarkServerStub) Globber() *__ipc.GlobState {
Todd Wang702385a2014-11-07 01:54:08 -0800258 return s.gs
Robin Thellendcafaa492014-06-24 13:58:25 -0700259}
260
Todd Wang5739dda2014-11-16 22:44:02 -0800261func (s implBenchmarkServerStub) Describe__() []__ipc.InterfaceDesc {
262 return []__ipc.InterfaceDesc{BenchmarkDesc}
263}
264
265// BenchmarkDesc describes the Benchmark interface.
266var BenchmarkDesc __ipc.InterfaceDesc = descBenchmark
267
268// descBenchmark hides the desc to keep godoc clean.
269var descBenchmark = __ipc.InterfaceDesc{
270 Name: "Benchmark",
271 PkgPath: "veyron.io/veyron/veyron/runtimes/google/ipc/benchmarks",
272 Methods: []__ipc.MethodDesc{
273 {
274 Name: "Echo",
275 Doc: "// Echo returns the payload that it receives.",
276 InArgs: []__ipc.ArgDesc{
277 {"Payload", ``}, // []byte
278 },
279 OutArgs: []__ipc.ArgDesc{
280 {"", ``}, // []byte
281 {"", ``}, // error
282 },
283 },
284 {
285 Name: "EchoStream",
286 Doc: "// EchoStream returns the payload that it receives via the stream.",
287 OutArgs: []__ipc.ArgDesc{
288 {"", ``}, // error
289 },
290 },
291 },
Robin Thellendcafaa492014-06-24 13:58:25 -0700292}
293
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800294func (s implBenchmarkServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
Todd Wang5739dda2014-11-16 22:44:02 -0800295 // TODO(toddw): Replace with new Describe__ implementation.
Todd Wang702385a2014-11-07 01:54:08 -0800296 result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
297 result.Methods["Echo"] = __ipc.MethodSignature{
298 InArgs: []__ipc.MethodArgument{
Robin Thellendcafaa492014-06-24 13:58:25 -0700299 {Name: "Payload", Type: 66},
300 },
Todd Wang702385a2014-11-07 01:54:08 -0800301 OutArgs: []__ipc.MethodArgument{
Robin Thellendcafaa492014-06-24 13:58:25 -0700302 {Name: "", Type: 66},
303 {Name: "", Type: 67},
304 },
305 }
Todd Wang702385a2014-11-07 01:54:08 -0800306 result.Methods["EchoStream"] = __ipc.MethodSignature{
307 InArgs: []__ipc.MethodArgument{},
308 OutArgs: []__ipc.MethodArgument{
Robin Thellendcafaa492014-06-24 13:58:25 -0700309 {Name: "", Type: 67},
310 },
311 InStream: 66,
312 OutStream: 66,
313 }
314
Todd Wang702385a2014-11-07 01:54:08 -0800315 result.TypeDefs = []__vdlutil.Any{
316 __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
Robin Thellendcafaa492014-06-24 13:58:25 -0700317
318 return result, nil
319}
320
Todd Wang702385a2014-11-07 01:54:08 -0800321// BenchmarkEchoStreamServerStream is the server stream for Benchmark.EchoStream.
322type BenchmarkEchoStreamServerStream interface {
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800323 // RecvStream returns the receiver side of the Benchmark.EchoStream server stream.
Todd Wang702385a2014-11-07 01:54:08 -0800324 RecvStream() interface {
325 // Advance stages an item so that it may be retrieved via Value. Returns
326 // true iff there is an item to retrieve. Advance must be called before
327 // Value is called. May block if an item is not available.
328 Advance() bool
329 // Value returns the item that was staged by Advance. May panic if Advance
330 // returned false or was not called. Never blocks.
331 Value() []byte
332 // Err returns any error encountered by Advance. Never blocks.
333 Err() error
Robin Thellendcafaa492014-06-24 13:58:25 -0700334 }
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800335 // SendStream returns the send side of the Benchmark.EchoStream server stream.
Todd Wang702385a2014-11-07 01:54:08 -0800336 SendStream() interface {
337 // Send places the item onto the output stream. Returns errors encountered
338 // while sending. Blocks if there is no buffer space; will unblock when
339 // buffer space is available.
340 Send(item []byte) error
Robin Thellendcafaa492014-06-24 13:58:25 -0700341 }
Robin Thellendcafaa492014-06-24 13:58:25 -0700342}
343
Todd Wang702385a2014-11-07 01:54:08 -0800344// BenchmarkEchoStreamContext represents the context passed to Benchmark.EchoStream.
345type BenchmarkEchoStreamContext interface {
346 __ipc.ServerContext
347 BenchmarkEchoStreamServerStream
Robin Thellend94bc4642014-11-05 18:05:08 -0800348}
349
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800350// BenchmarkEchoStreamContextStub is a wrapper that converts ipc.ServerCall into
351// a typesafe stub that implements BenchmarkEchoStreamContext.
352type BenchmarkEchoStreamContextStub struct {
353 __ipc.ServerCall
354 valRecv []byte
355 errRecv error
Robin Thellendcafaa492014-06-24 13:58:25 -0700356}
357
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800358// Init initializes BenchmarkEchoStreamContextStub from ipc.ServerCall.
359func (s *BenchmarkEchoStreamContextStub) Init(call __ipc.ServerCall) {
360 s.ServerCall = call
Todd Wang702385a2014-11-07 01:54:08 -0800361}
362
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800363// RecvStream returns the receiver side of the Benchmark.EchoStream server stream.
364func (s *BenchmarkEchoStreamContextStub) RecvStream() interface {
Todd Wang702385a2014-11-07 01:54:08 -0800365 Advance() bool
366 Value() []byte
367 Err() error
368} {
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800369 return implBenchmarkEchoStreamContextRecv{s}
Todd Wang702385a2014-11-07 01:54:08 -0800370}
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800371
372type implBenchmarkEchoStreamContextRecv struct {
373 s *BenchmarkEchoStreamContextStub
374}
375
376func (s implBenchmarkEchoStreamContextRecv) Advance() bool {
377 s.s.errRecv = s.s.Recv(&s.s.valRecv)
378 return s.s.errRecv == nil
379}
380func (s implBenchmarkEchoStreamContextRecv) Value() []byte {
381 return s.s.valRecv
382}
383func (s implBenchmarkEchoStreamContextRecv) Err() error {
384 if s.s.errRecv == __io.EOF {
385 return nil
386 }
387 return s.s.errRecv
388}
389
390// SendStream returns the send side of the Benchmark.EchoStream server stream.
391func (s *BenchmarkEchoStreamContextStub) SendStream() interface {
Todd Wang702385a2014-11-07 01:54:08 -0800392 Send(item []byte) error
393} {
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800394 return implBenchmarkEchoStreamContextSend{s}
395}
396
397type implBenchmarkEchoStreamContextSend struct {
398 s *BenchmarkEchoStreamContextStub
399}
400
401func (s implBenchmarkEchoStreamContextSend) Send(item []byte) error {
402 return s.s.Send(item)
Robin Thellendcafaa492014-06-24 13:58:25 -0700403}