mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-25 21:26:03 +03:00
fix words for retrier pattern
This commit is contained in:
parent
4b57a7af7e
commit
78a2c3922b
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user