Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 1 | // 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. |
| 6 | package benchmarks |
| 7 | |
| 8 | import ( |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 9 | // 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 Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 16 | ) |
| 17 | |
Jing Jin | 896d776 | 2014-11-03 11:18:52 -0800 | [diff] [blame] | 18 | // TODO(toddw): Remove this line once the new signature support is done. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 19 | // It corrects a bug where __wiretype is unused in VDL pacakges where only |
Jing Jin | 896d776 | 2014-11-03 11:18:52 -0800 | [diff] [blame] | 20 | // bootstrap types are used on interfaces. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 21 | const _ = __wiretype.TypeIDInvalid |
Shyam Jayaraman | c4aed6e | 2014-07-22 14:25:06 -0700 | [diff] [blame] | 22 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 23 | // BenchmarkClientMethods is the client interface |
| 24 | // containing Benchmark methods. |
| 25 | type BenchmarkClientMethods interface { |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 26 | // Echo returns the payload that it receives. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 27 | Echo(ctx __context.T, Payload []byte, opts ...__ipc.CallOpt) ([]byte, error) |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 28 | // EchoStream returns the payload that it receives via the stream. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 29 | EchoStream(__context.T, ...__ipc.CallOpt) (BenchmarkEchoStreamCall, error) |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 32 | // BenchmarkClientStub adds universal methods to BenchmarkClientMethods. |
| 33 | type BenchmarkClientStub interface { |
| 34 | BenchmarkClientMethods |
| 35 | __ipc.UniversalServiceMethods |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 38 | // BenchmarkClient returns a client stub for Benchmark. |
| 39 | func 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 | |
| 49 | type implBenchmarkClientStub struct { |
| 50 | name string |
| 51 | client __ipc.Client |
| 52 | } |
| 53 | |
| 54 | func (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 | |
| 61 | func (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 | |
| 72 | func (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 Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 77 | ocall = &implBenchmarkEchoStreamCall{Call: call} |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 78 | return |
| 79 | } |
| 80 | |
| 81 | func (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 Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 92 | // BenchmarkEchoStreamClientStream is the client stream for Benchmark.EchoStream. |
| 93 | type BenchmarkEchoStreamClientStream interface { |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 94 | // RecvStream returns the receiver side of the Benchmark.EchoStream client stream. |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 95 | RecvStream() interface { |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 96 | // 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 Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 99 | Advance() bool |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 100 | // Value returns the item that was staged by Advance. May panic if Advance |
| 101 | // returned false or was not called. Never blocks. |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 102 | Value() []byte |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 103 | // Err returns any error encountered by Advance. Never blocks. |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 104 | Err() error |
| 105 | } |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 106 | // SendStream returns the send side of the Benchmark.EchoStream client stream. |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 107 | SendStream() interface { |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 108 | // 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 Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 112 | Send(item []byte) error |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 113 | // 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 Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 119 | Close() error |
| 120 | } |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 121 | } |
Shyam Jayaraman | c4aed6e | 2014-07-22 14:25:06 -0700 | [diff] [blame] | 122 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 123 | // BenchmarkEchoStreamCall represents the call returned from Benchmark.EchoStream. |
| 124 | type 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 Jayaraman | c4aed6e | 2014-07-22 14:25:06 -0700 | [diff] [blame] | 132 | // |
| 133 | // Calling Finish is mandatory for releasing stream resources, unless Cancel |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 134 | // 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 Jayaraman | c4aed6e | 2014-07-22 14:25:06 -0700 | [diff] [blame] | 139 | // Calling Cancel after Finish has returned is a no-op. |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 140 | Cancel() |
| 141 | } |
| 142 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 143 | type implBenchmarkEchoStreamCall struct { |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 144 | __ipc.Call |
| 145 | valRecv []byte |
| 146 | errRecv error |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | func (c *implBenchmarkEchoStreamCall) RecvStream() interface { |
| 150 | Advance() bool |
| 151 | Value() []byte |
| 152 | Err() error |
| 153 | } { |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 154 | return implBenchmarkEchoStreamCallRecv{c} |
| 155 | } |
| 156 | |
| 157 | type implBenchmarkEchoStreamCallRecv struct { |
| 158 | c *implBenchmarkEchoStreamCall |
| 159 | } |
| 160 | |
| 161 | func (c implBenchmarkEchoStreamCallRecv) Advance() bool { |
| 162 | c.c.errRecv = c.c.Recv(&c.c.valRecv) |
| 163 | return c.c.errRecv == nil |
| 164 | } |
| 165 | func (c implBenchmarkEchoStreamCallRecv) Value() []byte { |
| 166 | return c.c.valRecv |
| 167 | } |
| 168 | func (c implBenchmarkEchoStreamCallRecv) Err() error { |
| 169 | if c.c.errRecv == __io.EOF { |
| 170 | return nil |
| 171 | } |
| 172 | return c.c.errRecv |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 173 | } |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 174 | func (c *implBenchmarkEchoStreamCall) SendStream() interface { |
| 175 | Send(item []byte) error |
| 176 | Close() error |
| 177 | } { |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 178 | return implBenchmarkEchoStreamCallSend{c} |
| 179 | } |
| 180 | |
| 181 | type implBenchmarkEchoStreamCallSend struct { |
| 182 | c *implBenchmarkEchoStreamCall |
| 183 | } |
| 184 | |
| 185 | func (c implBenchmarkEchoStreamCallSend) Send(item []byte) error { |
| 186 | return c.c.Send(item) |
| 187 | } |
| 188 | func (c implBenchmarkEchoStreamCallSend) Close() error { |
| 189 | return c.c.CloseSend() |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 190 | } |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 191 | func (c *implBenchmarkEchoStreamCall) Finish() (err error) { |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 192 | if ierr := c.Call.Finish(&err); ierr != nil { |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 193 | err = ierr |
| 194 | } |
| 195 | return |
| 196 | } |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 197 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 198 | // BenchmarkServerMethods is the interface a server writer |
| 199 | // implements for Benchmark. |
| 200 | type 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 Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 207 | // BenchmarkServerStubMethods is the server interface containing |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 208 | // Benchmark methods, as expected by ipc.Server. |
| 209 | // The only difference between this interface and BenchmarkServerMethods |
| 210 | // is the streaming methods. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 211 | type BenchmarkServerStubMethods interface { |
| 212 | // Echo returns the payload that it receives. |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 213 | Echo(ctx __ipc.ServerContext, Payload []byte) ([]byte, error) |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 214 | // EchoStream returns the payload that it receives via the stream. |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 215 | EchoStream(*BenchmarkEchoStreamContextStub) error |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 218 | // BenchmarkServerStub adds universal methods to BenchmarkServerStubMethods. |
| 219 | type BenchmarkServerStub interface { |
| 220 | BenchmarkServerStubMethods |
Todd Wang | 5739dda | 2014-11-16 22:44:02 -0800 | [diff] [blame] | 221 | // Describe the Benchmark interfaces. |
| 222 | Describe__() []__ipc.InterfaceDesc |
| 223 | // Signature will be replaced with Describe__. |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 224 | Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 225 | } |
| 226 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 227 | // 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. |
| 230 | func BenchmarkServer(impl BenchmarkServerMethods) BenchmarkServerStub { |
| 231 | stub := implBenchmarkServerStub{ |
| 232 | impl: impl, |
Shyam Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 233 | } |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 234 | // 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 Jayaraman | 97b9dca | 2014-07-31 13:30:46 -0700 | [diff] [blame] | 240 | } |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame] | 241 | return stub |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 244 | type implBenchmarkServerStub struct { |
| 245 | impl BenchmarkServerMethods |
| 246 | gs *__ipc.GlobState |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 249 | func (s implBenchmarkServerStub) Echo(ctx __ipc.ServerContext, i0 []byte) ([]byte, error) { |
| 250 | return s.impl.Echo(ctx, i0) |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 253 | func (s implBenchmarkServerStub) EchoStream(ctx *BenchmarkEchoStreamContextStub) error { |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 254 | return s.impl.EchoStream(ctx) |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Robin Thellend | 39ac323 | 2014-12-02 09:50:41 -0800 | [diff] [blame] | 257 | func (s implBenchmarkServerStub) Globber() *__ipc.GlobState { |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 258 | return s.gs |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Todd Wang | 5739dda | 2014-11-16 22:44:02 -0800 | [diff] [blame] | 261 | func (s implBenchmarkServerStub) Describe__() []__ipc.InterfaceDesc { |
| 262 | return []__ipc.InterfaceDesc{BenchmarkDesc} |
| 263 | } |
| 264 | |
| 265 | // BenchmarkDesc describes the Benchmark interface. |
| 266 | var BenchmarkDesc __ipc.InterfaceDesc = descBenchmark |
| 267 | |
| 268 | // descBenchmark hides the desc to keep godoc clean. |
| 269 | var 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 Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 294 | func (s implBenchmarkServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) { |
Todd Wang | 5739dda | 2014-11-16 22:44:02 -0800 | [diff] [blame] | 295 | // TODO(toddw): Replace with new Describe__ implementation. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 296 | result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)} |
| 297 | result.Methods["Echo"] = __ipc.MethodSignature{ |
| 298 | InArgs: []__ipc.MethodArgument{ |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 299 | {Name: "Payload", Type: 66}, |
| 300 | }, |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 301 | OutArgs: []__ipc.MethodArgument{ |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 302 | {Name: "", Type: 66}, |
| 303 | {Name: "", Type: 67}, |
| 304 | }, |
| 305 | } |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 306 | result.Methods["EchoStream"] = __ipc.MethodSignature{ |
| 307 | InArgs: []__ipc.MethodArgument{}, |
| 308 | OutArgs: []__ipc.MethodArgument{ |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 309 | {Name: "", Type: 67}, |
| 310 | }, |
| 311 | InStream: 66, |
| 312 | OutStream: 66, |
| 313 | } |
| 314 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 315 | 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 Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 317 | |
| 318 | return result, nil |
| 319 | } |
| 320 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 321 | // BenchmarkEchoStreamServerStream is the server stream for Benchmark.EchoStream. |
| 322 | type BenchmarkEchoStreamServerStream interface { |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 323 | // RecvStream returns the receiver side of the Benchmark.EchoStream server stream. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 324 | 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 Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 334 | } |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 335 | // SendStream returns the send side of the Benchmark.EchoStream server stream. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 336 | 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 Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 341 | } |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 342 | } |
| 343 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 344 | // BenchmarkEchoStreamContext represents the context passed to Benchmark.EchoStream. |
| 345 | type BenchmarkEchoStreamContext interface { |
| 346 | __ipc.ServerContext |
| 347 | BenchmarkEchoStreamServerStream |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame] | 348 | } |
| 349 | |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 350 | // BenchmarkEchoStreamContextStub is a wrapper that converts ipc.ServerCall into |
| 351 | // a typesafe stub that implements BenchmarkEchoStreamContext. |
| 352 | type BenchmarkEchoStreamContextStub struct { |
| 353 | __ipc.ServerCall |
| 354 | valRecv []byte |
| 355 | errRecv error |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 356 | } |
| 357 | |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 358 | // Init initializes BenchmarkEchoStreamContextStub from ipc.ServerCall. |
| 359 | func (s *BenchmarkEchoStreamContextStub) Init(call __ipc.ServerCall) { |
| 360 | s.ServerCall = call |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 361 | } |
| 362 | |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 363 | // RecvStream returns the receiver side of the Benchmark.EchoStream server stream. |
| 364 | func (s *BenchmarkEchoStreamContextStub) RecvStream() interface { |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 365 | Advance() bool |
| 366 | Value() []byte |
| 367 | Err() error |
| 368 | } { |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 369 | return implBenchmarkEchoStreamContextRecv{s} |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 370 | } |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 371 | |
| 372 | type implBenchmarkEchoStreamContextRecv struct { |
| 373 | s *BenchmarkEchoStreamContextStub |
| 374 | } |
| 375 | |
| 376 | func (s implBenchmarkEchoStreamContextRecv) Advance() bool { |
| 377 | s.s.errRecv = s.s.Recv(&s.s.valRecv) |
| 378 | return s.s.errRecv == nil |
| 379 | } |
| 380 | func (s implBenchmarkEchoStreamContextRecv) Value() []byte { |
| 381 | return s.s.valRecv |
| 382 | } |
| 383 | func (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. |
| 391 | func (s *BenchmarkEchoStreamContextStub) SendStream() interface { |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 392 | Send(item []byte) error |
| 393 | } { |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 394 | return implBenchmarkEchoStreamContextSend{s} |
| 395 | } |
| 396 | |
| 397 | type implBenchmarkEchoStreamContextSend struct { |
| 398 | s *BenchmarkEchoStreamContextStub |
| 399 | } |
| 400 | |
| 401 | func (s implBenchmarkEchoStreamContextSend) Send(item []byte) error { |
| 402 | return s.s.Send(item) |
Robin Thellend | cafaa49 | 2014-06-24 13:58:25 -0700 | [diff] [blame] | 403 | } |