Retry retries `f` up to `count` times at interval. If after `count` attempts there is an error, the command chain is terminated with the final error. retryCount starts from 1.
(stage string, interval time.Duration, count int, f func(retryCount int) error)
| 149 | // If after `count` attempts there is an error, the command chain is terminated with the final error. |
| 150 | // retryCount starts from 1. |
| 151 | func (a *ActiveCommandChain) Retry(stage string, interval time.Duration, count int, f func(retryCount int) error) { |
| 152 | a.Add(func() (err error) { |
| 153 | var i int |
| 154 | for err = f(i + 1); i < count && err != nil; i, err = i+1, f(i+1) { |
| 155 | if stage != "" { |
| 156 | a.log.Println(stage, "...") |
| 157 | } |
| 158 | time.Sleep(interval) |
| 159 | } |
| 160 | return err |
| 161 | }) |
| 162 | } |
no test coverage detected