File tree 6 files changed +27
-27
lines changed
6 files changed +27
-27
lines changed Original file line number Diff line number Diff line change 57
57
go build
58
58
59
59
release : # # Release new version
60
- git tag | grep -q $(VERSION ) && echo This version was released! Increase VERSION! || git tag $(VERSION ) && git push origin $(VERSION )
60
+ git tag | grep -q $(VERSION ) && echo This version was released! Increase VERSION! || git tag $(VERSION ) && git push origin $(VERSION ) && git tag v $( VERSION ) && git push origin v $( VERSION )
61
61
62
62
# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
63
63
help :
Original file line number Diff line number Diff line change @@ -64,6 +64,15 @@ nonintuitive interface (for me)
64
64
65
65
### BREAKING CHANGES
66
66
67
+ 1.0.2 -> 2.0.0
68
+
69
+ * argument of ` retry.Delay ` is final delay (no multiplication by ` retry.Units `
70
+ anymore)
71
+
72
+ * function ` retry.Units ` are removed
73
+
74
+ * [ more about this breaking change] ( https://github.com/avast/retry-go/issues/7 )
75
+
67
76
0.3.0 -> 1.0.0
68
77
69
78
* ` retry.Retry ` function are changed to ` retry.Do ` function
@@ -133,7 +142,7 @@ Attempts set count of retry default is 10
133
142
```go
134
143
func Delay(delay time.Duration) Option
135
144
```
136
- Delay set delay between retry default are 1e5 units
145
+ Delay set delay between retry default is 100ms
137
146
138
147
#### func OnRetry
139
148
@@ -175,14 +184,6 @@ skip retry if special error example:
175
184
})
176
185
)
177
186
178
- #### func Units
179
-
180
- ` ` ` go
181
- func Units(units time.Duration) Option
182
- ` ` `
183
- Units set unit of delay (probably only for tests purpose) default are
184
- microsecond
185
-
186
187
#### type RetryIfFunc
187
188
188
189
` ` ` go
Original file line number Diff line number Diff line change 1
- 1 .0.2
1
+ 2 .0.0
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ type OnRetryFunc func(n uint, err error)
14
14
type config struct {
15
15
attempts uint
16
16
delay time.Duration
17
- units time.Duration
18
17
onRetry OnRetryFunc
19
18
retryIf RetryIfFunc
20
19
}
@@ -31,21 +30,13 @@ func Attempts(attempts uint) Option {
31
30
}
32
31
33
32
// Delay set delay between retry
34
- // default are 1e5 units
33
+ // default is 100ms
35
34
func Delay (delay time.Duration ) Option {
36
35
return func (c * config ) {
37
36
c .delay = delay
38
37
}
39
38
}
40
39
41
- // Units set unit of delay (probably only for tests purpose)
42
- // default are microsecond
43
- func Units (units time.Duration ) Option {
44
- return func (c * config ) {
45
- c .units = units
46
- }
47
- }
48
-
49
40
// OnRetry function callback are called each retry
50
41
//
51
42
// log each retry example:
@@ -54,7 +45,7 @@ func Units(units time.Duration) Option {
54
45
// func() error {
55
46
// return errors.New("some error")
56
47
// },
57
- // retry.OnRetry(func(n unit , err error) {
48
+ // retry.OnRetry(func(n uint , err error) {
58
49
// log.Printf("#%d: %s\n", n, err)
59
50
// }),
60
51
// )
Original file line number Diff line number Diff line change @@ -45,6 +45,15 @@ SEE ALSO
45
45
46
46
BREAKING CHANGES
47
47
48
+ 1.0.2 -> 2.0.0
49
+
50
+ * argument of `retry.Delay` is final delay (no multiplication by `retry.Units` anymore)
51
+
52
+ * function `retry.Units` are removed
53
+
54
+ * [more about this breaking change](https://github.com/avast/retry-go/issues/7)
55
+
56
+
48
57
0.3.0 -> 1.0.0
49
58
50
59
* `retry.Retry` function are changed to `retry.Do` function
@@ -70,8 +79,7 @@ func Do(retryableFunc RetryableFunc, opts ...Option) error {
70
79
//default
71
80
config := & config {
72
81
attempts : 10 ,
73
- delay : 1e5 ,
74
- units : time .Microsecond ,
82
+ delay : 100 * time .Millisecond ,
75
83
onRetry : func (n uint , err error ) {},
76
84
retryIf : func (err error ) bool { return true },
77
85
}
@@ -100,7 +108,7 @@ func Do(retryableFunc RetryableFunc, opts ...Option) error {
100
108
}
101
109
102
110
delayTime := config .delay * (1 << (n - 1 ))
103
- time .Sleep (( time . Duration )( delayTime ) * config . units )
111
+ time .Sleep (delayTime )
104
112
} else {
105
113
return nil
106
114
}
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ func TestDoAllFailed(t *testing.T) {
13
13
err := Do (
14
14
func () error { return errors .New ("test" ) },
15
15
OnRetry (func (n uint , err error ) { retrySum += n }),
16
- Units (time .Nanosecond ),
16
+ Delay (time .Nanosecond ),
17
17
)
18
18
assert .Error (t , err )
19
19
@@ -57,7 +57,7 @@ func TestRetryIf(t *testing.T) {
57
57
RetryIf (func (err error ) bool {
58
58
return err .Error () != "special"
59
59
}),
60
- Units (time .Nanosecond ),
60
+ Delay (time .Nanosecond ),
61
61
)
62
62
assert .Error (t , err )
63
63
You can’t perform that action at this time.
0 commit comments