push
github
242 of 242 new or added lines in 7 files covered. (100.0%)
1095 of 1252 relevant lines covered (87.46%)
160.6 hits per line
1 |
package mssqlx
|
|
2 |
|
|
3 |
import (
|
|
4 |
"database/sql"
|
|
5 |
"time"
|
|
6 |
) |
|
7 |
|
|
|
func retryFunc(query string, f func() (interface{}, error)) (result interface{}, err error) { |
5,053✔ |
|
for retry := 0; retry < 50; retry++ { |
10,336✔ |
|
if result, err = f(); err == nil { |
10,316✔ |
|
return
|
5,033✔ |
|
} |
5,033✔ |
13 |
|
|
|
switch err {
|
250✔ |
|
case sql.ErrConnDone:
|
× |
16 |
|
|
|
case sql.ErrTxDone, sql.ErrNoRows:
|
4✔ |
|
return
|
4✔ |
19 |
|
|
|
default:
|
246✔ |
|
if isErrBadConn(err) || IsDeadlock(err) {
|
476✔ |
|
time.Sleep(5 * time.Millisecond)
|
230✔ |
|
} else {
|
246✔ |
|
return
|
16✔ |
|
} |
16✔ |
26 |
} |
|
27 |
} |
|
28 |
|
|
|
if err == sql.ErrConnDone || isErrBadConn(err) {
|
× |
|
reportError(query, err) |
× |
|
} |
× |
32 |
|
|
|
return
|
× |
34 |
} |