(database int32, seed uint, must bool)
| 459 | } |
| 460 | |
| 461 | func (s *sharedBackendConn) BackendConn(database int32, seed uint, must bool) *BackendConn { |
| 462 | if s == nil { |
| 463 | return nil |
| 464 | } |
| 465 | |
| 466 | if s.single != nil { |
| 467 | bc := s.single[database] |
| 468 | if must || bc.IsConnected() { |
| 469 | return bc |
| 470 | } |
| 471 | return nil |
| 472 | } |
| 473 | |
| 474 | var parallel = s.conns[database] |
| 475 | |
| 476 | var i = seed |
| 477 | for range parallel { |
| 478 | i = (i + 1) % uint(len(parallel)) |
| 479 | if bc := parallel[i]; bc.IsConnected() { |
| 480 | return bc |
| 481 | } |
| 482 | } |
| 483 | if !must { |
| 484 | return nil |
| 485 | } |
| 486 | return parallel[0] |
| 487 | } |
| 488 | |
| 489 | type sharedBackendConnPool struct { |
| 490 | config *Config |
no test coverage detected