Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 1 | // This file was auto-generated by the veyron vdl tool. |
| 2 | // Source: stress.vdl |
| 3 | |
| 4 | package stress |
| 5 | |
| 6 | import ( |
| 7 | // VDL system imports |
| 8 | "io" |
| 9 | "v.io/v23" |
| 10 | "v.io/v23/context" |
| 11 | "v.io/v23/ipc" |
| 12 | "v.io/v23/vdl" |
| 13 | |
| 14 | // VDL user imports |
| 15 | "v.io/v23/services/security/access" |
| 16 | ) |
| 17 | |
| 18 | type Arg struct { |
| 19 | ABool bool |
| 20 | AInt64 int64 |
| 21 | AListOfBytes []byte |
| 22 | } |
| 23 | |
| 24 | func (Arg) __VDLReflect(struct { |
Matt Rosencrantz | dbc1be2 | 2015-02-28 15:15:49 -0800 | [diff] [blame] | 25 | Name string "v.io/x/ref/profiles/internal/ipc/stress.Arg" |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 26 | }) { |
| 27 | } |
| 28 | |
| 29 | type Stats struct { |
| 30 | SumCount uint64 |
| 31 | SumStreamCount uint64 |
| 32 | } |
| 33 | |
| 34 | func (Stats) __VDLReflect(struct { |
Matt Rosencrantz | dbc1be2 | 2015-02-28 15:15:49 -0800 | [diff] [blame] | 35 | Name string "v.io/x/ref/profiles/internal/ipc/stress.Stats" |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 36 | }) { |
| 37 | } |
| 38 | |
| 39 | func init() { |
| 40 | vdl.Register((*Arg)(nil)) |
| 41 | vdl.Register((*Stats)(nil)) |
| 42 | } |
| 43 | |
| 44 | // StressClientMethods is the client interface |
| 45 | // containing Stress methods. |
| 46 | type StressClientMethods interface { |
| 47 | // Do returns the checksum of the payload that it receives. |
| 48 | Sum(ctx *context.T, arg Arg, opts ...ipc.CallOpt) ([]byte, error) |
| 49 | // DoStream returns the checksum of the payload that it receives via the stream. |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 50 | SumStream(*context.T, ...ipc.CallOpt) (StressSumStreamClientCall, error) |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 51 | // GetStats returns the stats on the calls that the server received. |
| 52 | GetStats(*context.T, ...ipc.CallOpt) (Stats, error) |
| 53 | // Stop stops the server. |
| 54 | Stop(*context.T, ...ipc.CallOpt) error |
| 55 | } |
| 56 | |
| 57 | // StressClientStub adds universal methods to StressClientMethods. |
| 58 | type StressClientStub interface { |
| 59 | StressClientMethods |
| 60 | ipc.UniversalServiceMethods |
| 61 | } |
| 62 | |
| 63 | // StressClient returns a client stub for Stress. |
| 64 | func StressClient(name string, opts ...ipc.BindOpt) StressClientStub { |
| 65 | var client ipc.Client |
| 66 | for _, opt := range opts { |
| 67 | if clientOpt, ok := opt.(ipc.Client); ok { |
| 68 | client = clientOpt |
| 69 | } |
| 70 | } |
| 71 | return implStressClientStub{name, client} |
| 72 | } |
| 73 | |
| 74 | type implStressClientStub struct { |
| 75 | name string |
| 76 | client ipc.Client |
| 77 | } |
| 78 | |
| 79 | func (c implStressClientStub) c(ctx *context.T) ipc.Client { |
| 80 | if c.client != nil { |
| 81 | return c.client |
| 82 | } |
| 83 | return v23.GetClient(ctx) |
| 84 | } |
| 85 | |
| 86 | func (c implStressClientStub) Sum(ctx *context.T, i0 Arg, opts ...ipc.CallOpt) (o0 []byte, err error) { |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 87 | var call ipc.ClientCall |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 88 | if call, err = c.c(ctx).StartCall(ctx, c.name, "Sum", []interface{}{i0}, opts...); err != nil { |
| 89 | return |
| 90 | } |
| 91 | err = call.Finish(&o0) |
| 92 | return |
| 93 | } |
| 94 | |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 95 | func (c implStressClientStub) SumStream(ctx *context.T, opts ...ipc.CallOpt) (ocall StressSumStreamClientCall, err error) { |
| 96 | var call ipc.ClientCall |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 97 | if call, err = c.c(ctx).StartCall(ctx, c.name, "SumStream", nil, opts...); err != nil { |
| 98 | return |
| 99 | } |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 100 | ocall = &implStressSumStreamClientCall{ClientCall: call} |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 101 | return |
| 102 | } |
| 103 | |
| 104 | func (c implStressClientStub) GetStats(ctx *context.T, opts ...ipc.CallOpt) (o0 Stats, err error) { |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 105 | var call ipc.ClientCall |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 106 | if call, err = c.c(ctx).StartCall(ctx, c.name, "GetStats", nil, opts...); err != nil { |
| 107 | return |
| 108 | } |
| 109 | err = call.Finish(&o0) |
| 110 | return |
| 111 | } |
| 112 | |
| 113 | func (c implStressClientStub) Stop(ctx *context.T, opts ...ipc.CallOpt) (err error) { |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 114 | var call ipc.ClientCall |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 115 | if call, err = c.c(ctx).StartCall(ctx, c.name, "Stop", nil, opts...); err != nil { |
| 116 | return |
| 117 | } |
| 118 | err = call.Finish() |
| 119 | return |
| 120 | } |
| 121 | |
| 122 | // StressSumStreamClientStream is the client stream for Stress.SumStream. |
| 123 | type StressSumStreamClientStream interface { |
| 124 | // RecvStream returns the receiver side of the Stress.SumStream client stream. |
| 125 | RecvStream() interface { |
| 126 | // Advance stages an item so that it may be retrieved via Value. Returns |
| 127 | // true iff there is an item to retrieve. Advance must be called before |
| 128 | // Value is called. May block if an item is not available. |
| 129 | Advance() bool |
| 130 | // Value returns the item that was staged by Advance. May panic if Advance |
| 131 | // returned false or was not called. Never blocks. |
| 132 | Value() []byte |
| 133 | // Err returns any error encountered by Advance. Never blocks. |
| 134 | Err() error |
| 135 | } |
| 136 | // SendStream returns the send side of the Stress.SumStream client stream. |
| 137 | SendStream() interface { |
| 138 | // Send places the item onto the output stream. Returns errors |
| 139 | // encountered while sending, or if Send is called after Close or |
| 140 | // the stream has been canceled. Blocks if there is no buffer |
| 141 | // space; will unblock when buffer space is available or after |
| 142 | // the stream has been canceled. |
| 143 | Send(item Arg) error |
| 144 | // Close indicates to the server that no more items will be sent; |
| 145 | // server Recv calls will receive io.EOF after all sent items. |
| 146 | // This is an optional call - e.g. a client might call Close if it |
| 147 | // needs to continue receiving items from the server after it's |
| 148 | // done sending. Returns errors encountered while closing, or if |
| 149 | // Close is called after the stream has been canceled. Like Send, |
| 150 | // blocks if there is no buffer space available. |
| 151 | Close() error |
| 152 | } |
| 153 | } |
| 154 | |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 155 | // StressSumStreamClientCall represents the call returned from Stress.SumStream. |
| 156 | type StressSumStreamClientCall interface { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 157 | StressSumStreamClientStream |
| 158 | // Finish performs the equivalent of SendStream().Close, then blocks until |
| 159 | // the server is done, and returns the positional return values for the call. |
| 160 | // |
| 161 | // Finish returns immediately if the call has been canceled; depending on the |
| 162 | // timing the output could either be an error signaling cancelation, or the |
| 163 | // valid positional return values from the server. |
| 164 | // |
| 165 | // Calling Finish is mandatory for releasing stream resources, unless the call |
| 166 | // has been canceled or any of the other methods return an error. Finish should |
| 167 | // be called at most once. |
| 168 | Finish() error |
| 169 | } |
| 170 | |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 171 | type implStressSumStreamClientCall struct { |
| 172 | ipc.ClientCall |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 173 | valRecv []byte |
| 174 | errRecv error |
| 175 | } |
| 176 | |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 177 | func (c *implStressSumStreamClientCall) RecvStream() interface { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 178 | Advance() bool |
| 179 | Value() []byte |
| 180 | Err() error |
| 181 | } { |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 182 | return implStressSumStreamClientCallRecv{c} |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 183 | } |
| 184 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 185 | type implStressSumStreamClientCallRecv struct { |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 186 | c *implStressSumStreamClientCall |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 187 | } |
| 188 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 189 | func (c implStressSumStreamClientCallRecv) Advance() bool { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 190 | c.c.errRecv = c.c.Recv(&c.c.valRecv) |
| 191 | return c.c.errRecv == nil |
| 192 | } |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 193 | func (c implStressSumStreamClientCallRecv) Value() []byte { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 194 | return c.c.valRecv |
| 195 | } |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 196 | func (c implStressSumStreamClientCallRecv) Err() error { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 197 | if c.c.errRecv == io.EOF { |
| 198 | return nil |
| 199 | } |
| 200 | return c.c.errRecv |
| 201 | } |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 202 | func (c *implStressSumStreamClientCall) SendStream() interface { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 203 | Send(item Arg) error |
| 204 | Close() error |
| 205 | } { |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 206 | return implStressSumStreamClientCallSend{c} |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 207 | } |
| 208 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 209 | type implStressSumStreamClientCallSend struct { |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 210 | c *implStressSumStreamClientCall |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 211 | } |
| 212 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 213 | func (c implStressSumStreamClientCallSend) Send(item Arg) error { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 214 | return c.c.Send(item) |
| 215 | } |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 216 | func (c implStressSumStreamClientCallSend) Close() error { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 217 | return c.c.CloseSend() |
| 218 | } |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 219 | func (c *implStressSumStreamClientCall) Finish() (err error) { |
| 220 | err = c.ClientCall.Finish() |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 221 | return |
| 222 | } |
| 223 | |
| 224 | // StressServerMethods is the interface a server writer |
| 225 | // implements for Stress. |
| 226 | type StressServerMethods interface { |
| 227 | // Do returns the checksum of the payload that it receives. |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 228 | Sum(call ipc.ServerCall, arg Arg) ([]byte, error) |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 229 | // DoStream returns the checksum of the payload that it receives via the stream. |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 230 | SumStream(StressSumStreamServerCall) error |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 231 | // GetStats returns the stats on the calls that the server received. |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 232 | GetStats(ipc.ServerCall) (Stats, error) |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 233 | // Stop stops the server. |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 234 | Stop(ipc.ServerCall) error |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | // StressServerStubMethods is the server interface containing |
| 238 | // Stress methods, as expected by ipc.Server. |
| 239 | // The only difference between this interface and StressServerMethods |
| 240 | // is the streaming methods. |
| 241 | type StressServerStubMethods interface { |
| 242 | // Do returns the checksum of the payload that it receives. |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 243 | Sum(call ipc.ServerCall, arg Arg) ([]byte, error) |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 244 | // DoStream returns the checksum of the payload that it receives via the stream. |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 245 | SumStream(*StressSumStreamServerCallStub) error |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 246 | // GetStats returns the stats on the calls that the server received. |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 247 | GetStats(ipc.ServerCall) (Stats, error) |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 248 | // Stop stops the server. |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 249 | Stop(ipc.ServerCall) error |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | // StressServerStub adds universal methods to StressServerStubMethods. |
| 253 | type StressServerStub interface { |
| 254 | StressServerStubMethods |
| 255 | // Describe the Stress interfaces. |
| 256 | Describe__() []ipc.InterfaceDesc |
| 257 | } |
| 258 | |
| 259 | // StressServer returns a server stub for Stress. |
| 260 | // It converts an implementation of StressServerMethods into |
| 261 | // an object that may be used by ipc.Server. |
| 262 | func StressServer(impl StressServerMethods) StressServerStub { |
| 263 | stub := implStressServerStub{ |
| 264 | impl: impl, |
| 265 | } |
| 266 | // Initialize GlobState; always check the stub itself first, to handle the |
| 267 | // case where the user has the Glob method defined in their VDL source. |
| 268 | if gs := ipc.NewGlobState(stub); gs != nil { |
| 269 | stub.gs = gs |
| 270 | } else if gs := ipc.NewGlobState(impl); gs != nil { |
| 271 | stub.gs = gs |
| 272 | } |
| 273 | return stub |
| 274 | } |
| 275 | |
| 276 | type implStressServerStub struct { |
| 277 | impl StressServerMethods |
| 278 | gs *ipc.GlobState |
| 279 | } |
| 280 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 281 | func (s implStressServerStub) Sum(call ipc.ServerCall, i0 Arg) ([]byte, error) { |
| 282 | return s.impl.Sum(call, i0) |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 283 | } |
| 284 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 285 | func (s implStressServerStub) SumStream(call *StressSumStreamServerCallStub) error { |
| 286 | return s.impl.SumStream(call) |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 287 | } |
| 288 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 289 | func (s implStressServerStub) GetStats(call ipc.ServerCall) (Stats, error) { |
| 290 | return s.impl.GetStats(call) |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 291 | } |
| 292 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 293 | func (s implStressServerStub) Stop(call ipc.ServerCall) error { |
| 294 | return s.impl.Stop(call) |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | func (s implStressServerStub) Globber() *ipc.GlobState { |
| 298 | return s.gs |
| 299 | } |
| 300 | |
| 301 | func (s implStressServerStub) Describe__() []ipc.InterfaceDesc { |
| 302 | return []ipc.InterfaceDesc{StressDesc} |
| 303 | } |
| 304 | |
| 305 | // StressDesc describes the Stress interface. |
| 306 | var StressDesc ipc.InterfaceDesc = descStress |
| 307 | |
| 308 | // descStress hides the desc to keep godoc clean. |
| 309 | var descStress = ipc.InterfaceDesc{ |
| 310 | Name: "Stress", |
Matt Rosencrantz | dbc1be2 | 2015-02-28 15:15:49 -0800 | [diff] [blame] | 311 | PkgPath: "v.io/x/ref/profiles/internal/ipc/stress", |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 312 | Methods: []ipc.MethodDesc{ |
| 313 | { |
| 314 | Name: "Sum", |
| 315 | Doc: "// Do returns the checksum of the payload that it receives.", |
| 316 | InArgs: []ipc.ArgDesc{ |
| 317 | {"arg", ``}, // Arg |
| 318 | }, |
| 319 | OutArgs: []ipc.ArgDesc{ |
| 320 | {"", ``}, // []byte |
| 321 | }, |
| 322 | Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))}, |
| 323 | }, |
| 324 | { |
| 325 | Name: "SumStream", |
| 326 | Doc: "// DoStream returns the checksum of the payload that it receives via the stream.", |
| 327 | Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))}, |
| 328 | }, |
| 329 | { |
| 330 | Name: "GetStats", |
| 331 | Doc: "// GetStats returns the stats on the calls that the server received.", |
| 332 | OutArgs: []ipc.ArgDesc{ |
| 333 | {"", ``}, // Stats |
| 334 | }, |
| 335 | Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))}, |
| 336 | }, |
| 337 | { |
| 338 | Name: "Stop", |
| 339 | Doc: "// Stop stops the server.", |
| 340 | Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Admin"))}, |
| 341 | }, |
| 342 | }, |
| 343 | } |
| 344 | |
| 345 | // StressSumStreamServerStream is the server stream for Stress.SumStream. |
| 346 | type StressSumStreamServerStream interface { |
| 347 | // RecvStream returns the receiver side of the Stress.SumStream server stream. |
| 348 | RecvStream() interface { |
| 349 | // Advance stages an item so that it may be retrieved via Value. Returns |
| 350 | // true iff there is an item to retrieve. Advance must be called before |
| 351 | // Value is called. May block if an item is not available. |
| 352 | Advance() bool |
| 353 | // Value returns the item that was staged by Advance. May panic if Advance |
| 354 | // returned false or was not called. Never blocks. |
| 355 | Value() Arg |
| 356 | // Err returns any error encountered by Advance. Never blocks. |
| 357 | Err() error |
| 358 | } |
| 359 | // SendStream returns the send side of the Stress.SumStream server stream. |
| 360 | SendStream() interface { |
| 361 | // Send places the item onto the output stream. Returns errors encountered |
| 362 | // while sending. Blocks if there is no buffer space; will unblock when |
| 363 | // buffer space is available. |
| 364 | Send(item []byte) error |
| 365 | } |
| 366 | } |
| 367 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 368 | // StressSumStreamServerCall represents the context passed to Stress.SumStream. |
| 369 | type StressSumStreamServerCall interface { |
Matt Rosencrantz | 5c7ed21 | 2015-02-27 22:42:35 -0800 | [diff] [blame] | 370 | ipc.ServerCall |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 371 | StressSumStreamServerStream |
| 372 | } |
| 373 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 374 | // StressSumStreamServerCallStub is a wrapper that converts ipc.StreamServerCall into |
| 375 | // a typesafe stub that implements StressSumStreamServerCall. |
| 376 | type StressSumStreamServerCallStub struct { |
Matt Rosencrantz | 1dcd0a9 | 2015-02-27 11:05:59 -0800 | [diff] [blame] | 377 | ipc.StreamServerCall |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 378 | valRecv Arg |
| 379 | errRecv error |
| 380 | } |
| 381 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 382 | // Init initializes StressSumStreamServerCallStub from ipc.StreamServerCall. |
| 383 | func (s *StressSumStreamServerCallStub) Init(call ipc.StreamServerCall) { |
Matt Rosencrantz | 1dcd0a9 | 2015-02-27 11:05:59 -0800 | [diff] [blame] | 384 | s.StreamServerCall = call |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | // RecvStream returns the receiver side of the Stress.SumStream server stream. |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 388 | func (s *StressSumStreamServerCallStub) RecvStream() interface { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 389 | Advance() bool |
| 390 | Value() Arg |
| 391 | Err() error |
| 392 | } { |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 393 | return implStressSumStreamServerCallRecv{s} |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 394 | } |
| 395 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 396 | type implStressSumStreamServerCallRecv struct { |
| 397 | s *StressSumStreamServerCallStub |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 398 | } |
| 399 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 400 | func (s implStressSumStreamServerCallRecv) Advance() bool { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 401 | s.s.valRecv = Arg{} |
| 402 | s.s.errRecv = s.s.Recv(&s.s.valRecv) |
| 403 | return s.s.errRecv == nil |
| 404 | } |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 405 | func (s implStressSumStreamServerCallRecv) Value() Arg { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 406 | return s.s.valRecv |
| 407 | } |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 408 | func (s implStressSumStreamServerCallRecv) Err() error { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 409 | if s.s.errRecv == io.EOF { |
| 410 | return nil |
| 411 | } |
| 412 | return s.s.errRecv |
| 413 | } |
| 414 | |
| 415 | // SendStream returns the send side of the Stress.SumStream server stream. |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 416 | func (s *StressSumStreamServerCallStub) SendStream() interface { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 417 | Send(item []byte) error |
| 418 | } { |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 419 | return implStressSumStreamServerCallSend{s} |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 420 | } |
| 421 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 422 | type implStressSumStreamServerCallSend struct { |
| 423 | s *StressSumStreamServerCallStub |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 424 | } |
| 425 | |
Suharsh Sivakumar | 31f4985 | 2015-03-03 16:13:20 -0800 | [diff] [blame] | 426 | func (s implStressSumStreamServerCallSend) Send(item []byte) error { |
Jungho Ahn | 48d4307 | 2015-02-23 18:50:27 -0800 | [diff] [blame] | 427 | return s.s.Send(item) |
| 428 | } |