MCPcopy
hub / github.com/IBM/sarama / shouldCloseBrokerConn

Function shouldCloseBrokerConn

broker.go:1351–1382  ·  view source on GitHub ↗

shouldCloseBrokerConn reports whether a transport error should trigger closing.

(err error)

Source from the content-addressed store, hash-verified

1349
1350// shouldCloseBrokerConn reports whether a transport error should trigger closing.
1351func shouldCloseBrokerConn(err error) bool {
1352 if err == nil {
1353 return false
1354 }
1355
1356 if errors.Is(err, io.EOF) {
1357 return true
1358 }
1359
1360 if errors.Is(err, io.ErrUnexpectedEOF) {
1361 return true
1362 }
1363
1364 if errors.Is(err, io.ErrClosedPipe) {
1365 return true
1366 }
1367
1368 if errors.Is(err, net.ErrClosed) {
1369 return true
1370 }
1371
1372 if errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.ECONNABORTED) || errors.Is(err, syscall.EPIPE) || errors.Is(err, syscall.ENOTCONN) {
1373 return true
1374 }
1375
1376 var netErr net.Error
1377 if errors.As(err, &netErr) {
1378 return !netErr.Timeout()
1379 }
1380
1381 return false
1382}
1383
1384func (b *Broker) sendAndReceiveApiVersions(v int16) (*ApiVersionsResponse, error) {
1385 rb := &ApiVersionsRequest{

Callers 4

maybeCloseLockedMethod · 0.85
isRetriableBrokerErrorFunction · 0.85

Calls 1

IsMethod · 0.80

Tested by 1