github
138 of 138 new or added lines in 6 files covered. (100.0%)
1078 of 1233 relevant lines covered (87.43%)
165.43 hits per line
1 |
package mssqlx
|
|
2 |
|
|
3 |
import (
|
|
4 |
"time"
|
|
5 |
) |
|
6 |
|
|
7 |
func retryFunc(query string, f func() (interface{}, error)) (result interface{}, err error) { |
5,054✔ |
8 |
for retry := 0; retry < 50; retry++ { |
10,369✔ |
|
result, err = f() |
5,315✔ |
|
if err == nil || isStdErr(err) { |
10,353✔ |
11 |
return
|
5,038✔ |
12 |
} |
5,038✔ |
13 |
|
|
|
if isErrBadConn(err) || IsDeadlock(err) {
|
538✔ |
|
time.Sleep(5 * time.Millisecond)
|
261✔ |
|
continue
|
261✔ |
|
} else {
|
16✔ |
|
break
|
16✔ |
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
if isErrBadConn(err) {
|
16✔ |
23 |
reportError(query, err) |
× |
24 |
} |
× |
25 |
|
|
26 |
return
|
16✔ |
27 |
} |