package store

type PostgresPoolMetricsSnapshot struct {
	MaxConnections       int32
	TotalConnections     int32
	AcquiredConnections  int32
	IdleConnections      int32
	EmptyAcquireCount    int64
	CanceledAcquireCount int64
}

func (s *Store) PostgresPoolMetrics() PostgresPoolMetricsSnapshot {
	if s == nil || s.pool == nil {
		return PostgresPoolMetricsSnapshot{}
	}
	statistics := s.pool.Stat()
	return PostgresPoolMetricsSnapshot{
		MaxConnections:       statistics.MaxConns(),
		TotalConnections:     statistics.TotalConns(),
		AcquiredConnections:  statistics.AcquiredConns(),
		IdleConnections:      statistics.IdleConns(),
		EmptyAcquireCount:    statistics.EmptyAcquireCount(),
		CanceledAcquireCount: statistics.CanceledAcquireCount(),
	}
}
