| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 pubsub | 5 package pubsub |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "fmt" | 9 "fmt" |
| 10 "sync" | 10 "sync" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 ctx := o.Context | 198 ctx := o.Context |
| 199 if o.RPCTimeout > 0 { | 199 if o.RPCTimeout > 0 { |
| 200 var cancelFunc context.CancelFunc | 200 var cancelFunc context.CancelFunc |
| 201 ctx, cancelFunc = clock.WithTimeout(o, o.RPCTimeout) | 201 ctx, cancelFunc = clock.WithTimeout(o, o.RPCTimeout) |
| 202 defer cancelFunc() | 202 defer cancelFunc() |
| 203 } | 203 } |
| 204 | 204 |
| 205 messageID, err = o.Topic.Publish(ctx, message) | 205 messageID, err = o.Topic.Publish(ctx, message) |
| 206 if err == context.DeadlineExceeded { | 206 if err == context.DeadlineExceeded { |
| 207 // If we hit our publish deadline, retry. | 207 // If we hit our publish deadline, retry. |
| 208 » » » err = errors.WrapTransient(err) | 208 » » » err = retry.Tag.Apply(err) |
| 209 } else { | 209 } else { |
| 210 err = grpcutil.WrapIfTransient(err) | 210 err = grpcutil.WrapIfTransient(err) |
| 211 } | 211 } |
| 212 return | 212 return |
| 213 }, func(err error, d time.Duration) { | 213 }, func(err error, d time.Duration) { |
| 214 log.Fields{ | 214 log.Fields{ |
| 215 log.ErrorKey: err, | 215 log.ErrorKey: err, |
| 216 "delay": d, | 216 "delay": d, |
| 217 }.Warningf(o, "TRANSIENT error publishing messages; retrying..."
) | 217 }.Warningf(o, "TRANSIENT error publishing messages; retrying..."
) |
| 218 transientErrors++ | 218 transientErrors++ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 248 // a maximum backoff. | 248 // a maximum backoff. |
| 249 func indefiniteRetry() retry.Iterator { | 249 func indefiniteRetry() retry.Iterator { |
| 250 return &retry.ExponentialBackoff{ | 250 return &retry.ExponentialBackoff{ |
| 251 Limited: retry.Limited{ | 251 Limited: retry.Limited{ |
| 252 Retries: -1, | 252 Retries: -1, |
| 253 Delay: 500 * time.Millisecond, | 253 Delay: 500 * time.Millisecond, |
| 254 }, | 254 }, |
| 255 MaxDelay: 30 * time.Second, | 255 MaxDelay: 30 * time.Second, |
| 256 } | 256 } |
| 257 } | 257 } |
| OLD | NEW |