mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
Compare commits
2 Commits
c175b202de
...
9caf2ffb1c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9caf2ffb1c | ||
|
|
1a5c31fd02 |
@@ -8,7 +8,7 @@ algorithm 算法包实现一些基本算法,sort,search,lrucache。
|
||||
|
||||
- [https://github.com/duke-git/lancet/blob/main/algorithm/sort.go](https://github.com/duke-git/lancet/blob/main/algorithm/sort.go)
|
||||
- [https://github.com/duke-git/lancet/blob/main/algorithm/search.go](https://github.com/duke-git/lancet/blob/main/algorithm/search.go)
|
||||
- [https://github.com/duke-git/lancet/blob/main/algorithm/lru_cache.go](https://github.com/duke-git/lancet/blob/main/algorithm/lru_cache.go)
|
||||
- [https://github.com/duke-git/lancet/blob/main/algorithm/lrucache.go](https://github.com/duke-git/lancet/blob/main/algorithm/lrucache.go)
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Package algorithm implements some basic algorithm. eg. sort, search.
|
||||
|
||||
- [https://github.com/duke-git/lancet/blob/main/algorithm/sort.go](https://github.com/duke-git/lancet/blob/main/algorithm/sort.go)
|
||||
- [https://github.com/duke-git/lancet/blob/main/algorithm/search.go](https://github.com/duke-git/lancet/blob/main/algorithm/search.go)
|
||||
- [https://github.com/duke-git/lancet/blob/main/algorithm/lru_cache.go](https://github.com/duke-git/lancet/blob/main/algorithm/lru_cache.go)
|
||||
- [https://github.com/duke-git/lancet/blob/main/algorithm/lrucache.go](https://github.com/duke-git/lancet/blob/main/algorithm/lrucache.go)
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
|
||||
@@ -130,14 +130,16 @@ func Retry(retryFunc RetryFunc, opts ...Option) error {
|
||||
var i uint
|
||||
for i < config.retryTimes {
|
||||
err := retryFunc()
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if i < config.retryTimes-1 { // Only wait if it's not the last retry
|
||||
select {
|
||||
case <-time.After(config.backoffStrategy.CalculateInterval()):
|
||||
case <-config.context.Done():
|
||||
return errors.New("retry is cancelled")
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
i++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user