Skip to content

Commit

Permalink
Merge ebeb868 into 1e4cf3d
Browse files Browse the repository at this point in the history
  • Loading branch information
Jleagle authored Mar 5, 2019
2 parents 1e4cf3d + ebeb868 commit 5498fa6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion retry.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package backoff

import "time"
import (
"sync"
"time"
)

// An Operation is executing by Retry() or RetryNotify().
// The operation will be retried using a backoff policy if it returns an error.
Expand All @@ -23,9 +26,15 @@ type Notify func(error, time.Duration)
// failed operation returns.
func Retry(o Operation, b BackOff) error { return RetryNotify(o, b, nil) }

var retryMutex sync.Mutex

// RetryNotify calls notify function with the error and wait duration
// for each failed attempt before sleep.
func RetryNotify(operation Operation, b BackOff, notify Notify) error {

retryMutex.Lock()
defer retryMutex.Unlock()

var err error
var next time.Duration
var t *time.Timer
Expand Down

0 comments on commit 5498fa6

Please sign in to comment.