Merge pull request #126 from jesselucas/patch-1
Testing if LoadBalancer is nil before Retry
Peter Bourgon
8 years ago
14 | 14 | // balancer. Requests that return errors will be retried until they succeed, |
15 | 15 | // up to max times, or until the timeout is elapsed, whichever comes first. |
16 | 16 | func Retry(max int, timeout time.Duration, lb LoadBalancer) endpoint.Endpoint { |
17 | if lb == nil { | |
18 | panic("nil LoadBalancer") | |
19 | } | |
20 | ||
17 | 21 | return func(ctx context.Context, request interface{}) (interface{}, error) { |
18 | 22 | var ( |
19 | 23 | newctx, cancel = context.WithTimeout(ctx, timeout) |