()
| 552 | } |
| 553 | |
| 554 | func (p *Pool) checkMinConns() error { |
| 555 | // TotalConns can include ones that are being destroyed but we should have |
| 556 | // sleep(500ms) around all of the destroys to help prevent that from throwing |
| 557 | // off this check |
| 558 | |
| 559 | // Create the number of connections needed to get to both minConns and minIdleConns |
| 560 | stat := p.Stat() |
| 561 | toCreate := max(p.minConns-stat.TotalConns(), p.minIdleConns-stat.IdleConns()) |
| 562 | if toCreate > 0 { |
| 563 | return p.createIdleResources(context.Background(), int(toCreate)) |
| 564 | } |
| 565 | return nil |
| 566 | } |
| 567 | |
| 568 | func (p *Pool) createIdleResources(parentCtx context.Context, targetResources int) error { |
| 569 | ctx, cancel := context.WithCancel(parentCtx) |
no test coverage detected