OLD | NEW |
1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package prpc | 5 package prpc |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "io/ioutil" | 9 "io/ioutil" |
10 "net/http" | 10 "net/http" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 client.Options.PerRPCTimeout = 10 * time.Second | 206 client.Options.PerRPCTimeout = 10 * time.Second |
207 client.Options.Retry = func() retry.Iterator { | 207 client.Options.Retry = func() retry.Iterator { |
208 return &countingRetryIterator{ | 208 return &countingRetryIterator{ |
209 retries: &retries, | 209 retries: &retries, |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 err := client.Call(ctx, "prpc.Greeter", "SayHell
o", req, res) | 213 err := client.Call(ctx, "prpc.Greeter", "SayHell
o", req, res) |
214 » » » » So(err.Error(), ShouldContainSubstring, "failed
to send request") | 214 » » » » So(err.Error(), ShouldEqual, context.DeadlineExc
eeded.Error()) |
215 So(retries, ShouldEqual, 0) | 215 So(retries, ShouldEqual, 0) |
216 }) | 216 }) |
217 | 217 |
218 Convey(`With a maximum content length smaller than the r
esponse, returns "ErrResponseTooBig".`, func(c C) { | 218 Convey(`With a maximum content length smaller than the r
esponse, returns "ErrResponseTooBig".`, func(c C) { |
219 client, server := setUp(sayHello(c)) | 219 client, server := setUp(sayHello(c)) |
220 defer server.Close() | 220 defer server.Close() |
221 | 221 |
222 client.MaxContentLength = 8 | 222 client.MaxContentLength = 8 |
223 err := client.Call(ctx, "prpc.Greeter", "SayHell
o", req, res) | 223 err := client.Call(ctx, "prpc.Greeter", "SayHell
o", req, res) |
224 So(err, ShouldEqual, ErrResponseTooBig) | 224 So(err, ShouldEqual, ErrResponseTooBig) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 retries *int | 333 retries *int |
334 } | 334 } |
335 | 335 |
336 func (it *countingRetryIterator) Next(c context.Context, err error) time.Duratio
n { | 336 func (it *countingRetryIterator) Next(c context.Context, err error) time.Duratio
n { |
337 *(it.retries)-- | 337 *(it.retries)-- |
338 if *it.retries <= 0 { | 338 if *it.retries <= 0 { |
339 return retry.Stop | 339 return retry.Stop |
340 } | 340 } |
341 return 0 | 341 return 0 |
342 } | 342 } |
OLD | NEW |