File tree 1 file changed +29
-8
lines changed 1 file changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,15 @@ An expressive, flexible retry package for Go.
6
6
7
7
## Features
8
8
9
- - Exponential backoff
10
- - Jitter
11
- - Bound to context
12
- - Bound to timeout
13
- - Bound to attempt count
14
- - Bound to certain kinds of errors
15
- - Any combination of the above
16
- - Retrying net.Listener wrapper
9
+ - Any combination of:
10
+ - Exponential backoff
11
+ - Jitter
12
+ - Bound to contexdt
13
+ - Bound to timeout
14
+ - Limit total attempt count
15
+ - Retry only on certain kinds of errors
16
+ - Defaults to retrying on all errors
17
+ - Retrying net.Listener wrapper
17
18
18
19
## Examples
19
20
@@ -53,3 +54,23 @@ err := retry.New(time.Millisecond).
53
54
)
54
55
fmt.Printf (" err: %v , took %v \n " , err, time.Since (start))
55
56
```
57
+
58
+ ---
59
+
60
+ This code may sleep anywhere from 500ms to 1.5s between attempts.
61
+
62
+ It will return the ` not enough time has elapsed ` error after about 10 seconds.
63
+
64
+ ``` go
65
+ start := time.Now ()
66
+
67
+ err := retry.New (time.Second ).
68
+ Jitter (0.5 ).
69
+ Timeout (time.Second * 10 ).
70
+ Run (
71
+ func () error {
72
+ return errors.New (" not enough time has elapsed" )
73
+ },
74
+ )
75
+ fmt.Printf (" err: %v , took %v \n " , err, time.Since (start))
76
+ ```
You can’t perform that action at this time.
0 commit comments