Skip to content

Commit

Permalink
Merge branch 'rc' of github.com:duke-git/lancet into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
duke-git committed Aug 30, 2024
2 parents ec092a0 + 159168d commit 5a38e34
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 52 deletions.
3 changes: 0 additions & 3 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,6 @@ import "github.com/duke-git/lancet/v2/retry"
- **<big>RetryFunc</big>** : 重试执行的函数。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/retry.md#RetryFunc)]
[[play](https://go.dev/play/p/nk2XRmagfVF)]
- **<big>RetryDuration</big>** : 设置重试间隔时间,默认 3 秒。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/retry.md#RetryDuration)]
[[play](https://go.dev/play/p/nk2XRmagfVF)]
- **<big>RetryTimes</big>** : 设置重试次数,默认 5。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/retry.md#RetryTimes)]
[[play](https://go.dev/play/p/ssfVeU2SwLO)]
Expand Down
52 changes: 3 additions & 49 deletions docs/api/packages/retry.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func main() {
return errors.New("error occurs")
}

duration := retry.RetryDuration(time.Microsecond*50)
duration := retry.RetryWithLinearBackoff(time.Microsecond*50)

retry.Retry(increaseNumber,
duration,
Expand Down Expand Up @@ -116,7 +116,7 @@ func main() {
return errors.New("error occurs")
}

duration := retry.RetryDuration(time.Microsecond*50)
duration := retry.RetryWithLinearBackoff(time.Microsecond*50)

err := retry.Retry(increaseNumber, duration)
if err != nil {
Expand Down Expand Up @@ -173,52 +173,6 @@ func main() {
}
```

### <span id="RetryDuration">RetryDuration</span>

<p>设置重试间隔时间,默认3秒</p>

<b>函数签名:</b>

```go
func RetryDuration(d time.Duration)
```

<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/nk2XRmagfVF)</span></b>

```go
package main

import (
"fmt"
"errors"
"log"
"github.com/duke-git/lancet/v2/retry"
)

func main() {
number := 0
increaseNumber := func() error {
number++
if number == 3 {
return nil
}
return errors.New("error occurs")
}

duration := retry.RetryDuration(time.Microsecond*50)

err := retry.Retry(increaseNumber, duration)
if err != nil {
return
}

fmt.Println(number)

// Output:
// 3
}
```

### <span id="Retry">Retry</span>

<p>重试执行函数retryFunc,直到函数运行成功,或被context停止</p>
Expand Down Expand Up @@ -251,7 +205,7 @@ func main() {
return errors.New("error occurs")
}

duration := retry.RetryDuration(time.Microsecond*50)
duration := retry.RetryWithLinearBackoff(time.Microsecond*50)

err := retry.Retry(increaseNumber, duration)
if err != nil {
Expand Down

0 comments on commit 5a38e34

Please sign in to comment.