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

Method triggerHealthCheck

pgxpool/pool.go:467–487  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

465}
466
467func (p *Pool) triggerHealthCheck() {
468 const healthCheckDelay = 500 * time.Millisecond
469
470 p.healthCheckMu.Lock()
471 defer p.healthCheckMu.Unlock()
472
473 if p.healthCheckTimer == nil {
474 // Destroy is asynchronous so we give it time to actually remove itself from
475 // the pool otherwise we might try to check the pool size too soon
476 p.healthCheckTimer = time.AfterFunc(healthCheckDelay, func() {
477 select {
478 case <-p.closeChan:
479 case p.healthCheckChan <- struct{}{}:
480 default:
481 }
482 })
483 return
484 }
485
486 p.healthCheckTimer.Reset(healthCheckDelay)
487}
488
489func (p *Pool) backgroundHealthCheck() {
490 ticker := time.NewTicker(p.healthCheckPeriod)

Callers 1

ReleaseMethod · 0.80

Calls 1

ResetMethod · 0.80

Tested by

no test coverage detected