github.com/songzhibin97/gkit@v1.2.13/distributed/retry/retry.go (about) 1 package retry 2 3 import ( 4 "context" 5 "time" 6 ) 7 8 func Retry() func(ctx context.Context) { 9 retryIn := 0 10 fibonacci := Fibonacci() 11 return func(ctx context.Context) { 12 if retryIn > 0 { 13 select { 14 case <-ctx.Done(): 15 break 16 case <-time.After(time.Second * time.Duration(retryIn)): 17 break 18 } 19 } 20 retryIn = fibonacci() 21 } 22 }