...

Source file src/github.com/jackc/pgx/v4/pgxpool/stat.go

Documentation: github.com/jackc/pgx/v4/pgxpool

     1  package pgxpool
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/jackc/puddle"
     7  )
     8  
     9  // Stat is a snapshot of Pool statistics.
    10  type Stat struct {
    11  	s                    *puddle.Stat
    12  	newConnsCount        int64
    13  	lifetimeDestroyCount int64
    14  	idleDestroyCount     int64
    15  }
    16  
    17  // AcquireCount returns the cumulative count of successful acquires from the pool.
    18  func (s *Stat) AcquireCount() int64 {
    19  	return s.s.AcquireCount()
    20  }
    21  
    22  // AcquireDuration returns the total duration of all successful acquires from
    23  // the pool.
    24  func (s *Stat) AcquireDuration() time.Duration {
    25  	return s.s.AcquireDuration()
    26  }
    27  
    28  // AcquiredConns returns the number of currently acquired connections in the pool.
    29  func (s *Stat) AcquiredConns() int32 {
    30  	return s.s.AcquiredResources()
    31  }
    32  
    33  // CanceledAcquireCount returns the cumulative count of acquires from the pool
    34  // that were canceled by a context.
    35  func (s *Stat) CanceledAcquireCount() int64 {
    36  	return s.s.CanceledAcquireCount()
    37  }
    38  
    39  // ConstructingConns returns the number of conns with construction in progress in
    40  // the pool.
    41  func (s *Stat) ConstructingConns() int32 {
    42  	return s.s.ConstructingResources()
    43  }
    44  
    45  // EmptyAcquireCount returns the cumulative count of successful acquires from the pool
    46  // that waited for a resource to be released or constructed because the pool was
    47  // empty.
    48  func (s *Stat) EmptyAcquireCount() int64 {
    49  	return s.s.EmptyAcquireCount()
    50  }
    51  
    52  // IdleConns returns the number of currently idle conns in the pool.
    53  func (s *Stat) IdleConns() int32 {
    54  	return s.s.IdleResources()
    55  }
    56  
    57  // MaxConns returns the maximum size of the pool.
    58  func (s *Stat) MaxConns() int32 {
    59  	return s.s.MaxResources()
    60  }
    61  
    62  // TotalConns returns the total number of resources currently in the pool.
    63  // The value is the sum of ConstructingConns, AcquiredConns, and
    64  // IdleConns.
    65  func (s *Stat) TotalConns() int32 {
    66  	return s.s.TotalResources()
    67  }
    68  
    69  // NewConnsCount returns the cumulative count of new connections opened.
    70  func (s *Stat) NewConnsCount() int64 {
    71  	return s.newConnsCount
    72  }
    73  
    74  // MaxLifetimeDestroyCount returns the cumulative count of connections destroyed
    75  // because they exceeded MaxConnLifetime.
    76  func (s *Stat) MaxLifetimeDestroyCount() int64 {
    77  	return s.lifetimeDestroyCount
    78  }
    79  
    80  // MaxIdleDestroyCount returns the cumulative count of connections destroyed because
    81  // they exceeded MaxConnIdleTime.
    82  func (s *Stat) MaxIdleDestroyCount() int64 {
    83  	return s.idleDestroyCount
    84  }
    85  

View as plain text