Skip to content

Commit

Permalink
fix #158: preserve context values
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Oct 29, 2020
1 parent 7a5261c commit a3f6ed5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func Do(
strategies ...func(strategy.Breaker, uint, error) bool,
) error {
var err, clean error
ctx, cancel := context.WithCancel(context.Background())
ctx, is := breaker.(context.Context)
if !is {
ctx = context.Background()
}
ctx, cancel := context.WithCancel(ctx)
for attempt, should := uint(0), true; should; attempt++ {
clean = unwrap(err)
for i, repeat := 0, len(strategies); should && i < repeat; i++ {
Expand Down

0 comments on commit a3f6ed5

Please sign in to comment.