(err error, allowTimeout bool, addr string)
| 183 | } |
| 184 | |
| 185 | func isBadConn(err error, allowTimeout bool, addr string) bool { |
| 186 | if err == nil { |
| 187 | return false |
| 188 | } |
| 189 | |
| 190 | // Check for context errors (works with wrapped errors) |
| 191 | if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { |
| 192 | return true |
| 193 | } |
| 194 | |
| 195 | // Check for pool timeout errors (works with wrapped errors) |
| 196 | if errors.Is(err, pool.ErrConnUnusableTimeout) { |
| 197 | return true |
| 198 | } |
| 199 | |
| 200 | if isRedisError(err) { |
| 201 | switch { |
| 202 | case isReadOnlyError(err): |
| 203 | // Close connections in read only state in case domain addr is used |
| 204 | // and domain resolves to a different Redis Server. See #790. |
| 205 | return true |
| 206 | case isMovedSameConnAddr(err, addr): |
| 207 | // Close connections when we are asked to move to the same addr |
| 208 | // of the connection. Force a DNS resolution when all connections |
| 209 | // of the pool are recycled |
| 210 | return true |
| 211 | default: |
| 212 | return false |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | if allowTimeout { |
| 217 | // Check for network timeout errors (works with wrapped errors) |
| 218 | var netErr net.Error |
| 219 | if errors.As(err, &netErr) && netErr.Timeout() { |
| 220 | return false |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | return true |
| 225 | } |
| 226 | |
| 227 | func isMovedError(err error) (moved bool, ask bool, addr string) { |
| 228 | // Check for typed MovedError |
no test coverage detected