MCPcopy
hub / github.com/jackc/pgx / checkMinConns

Method checkMinConns

pgxpool/pool.go:554–566  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

552}
553
554func (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
568func (p *Pool) createIdleResources(parentCtx context.Context, targetResources int) error {
569 ctx, cancel := context.WithCancel(parentCtx)

Callers 1

checkHealthMethod · 0.95

Calls 4

StatMethod · 0.95
createIdleResourcesMethod · 0.95
TotalConnsMethod · 0.80
IdleConnsMethod · 0.80

Tested by

no test coverage detected