fix words for retrier pattern

This commit is contained in:
Edward 2020-05-11 18:01:15 +08:00
parent 4b57a7af7e
commit 78a2c3922b
2 changed files with 15 additions and 2 deletions

View File

@ -80,7 +80,7 @@ func (r *Retrier) sleep(ctx context.Context, t <-chan time.Time) error {
} }
func (r *Retrier) calcSleep(i int) time.Duration { func (r *Retrier) calcSleep(i int) time.Duration {
// lock unsafe rand prng // lock unsafe rand prog
r.randMu.Lock() r.randMu.Lock()
defer r.randMu.Unlock() defer r.randMu.Unlock()
// take a random float in the range (-r.jitter, +r.jitter) and multiply it by the base amount // take a random float in the range (-r.jitter, +r.jitter) and multiply it by the base amount

View File

@ -1,3 +1,11 @@
/*
* @Description: https://github.com/crazybber
* @Author: Edward
* @Date: 2020-05-11 17:43:55
* @Last Modified by: Edward
* @Last Modified time: 2020-05-11 17:43:55
*/
package retrier package retrier
import ( import (
@ -7,7 +15,12 @@ import (
"time" "time"
) )
var i int var (
i int
errFoo = errors.New("work cancel")
errBar = errors.New("work cancel 2")
errBaz = errors.New("work cancel 3")
)
func genWork(returns []error) func() error { func genWork(returns []error) func() error {
i = 0 i = 0