Documentation
¶
Index ¶
- type ConnectionConfig
- type ConnectionPool
- func (cp *ConnectionPool) AddCluster(clusterID string, config ConnectionConfig) error
- func (cp *ConnectionPool) Close()
- func (cp *ConnectionPool) ExecuteQuery(ctx context.Context, clusterID, query string, args ...interface{}) error
- func (cp *ConnectionPool) GetAllClusters() []string
- func (cp *ConnectionPool) GetPool(clusterID string) (*pgxpool.Pool, error)
- func (cp *ConnectionPool) GetPoolStats(clusterID string) (map[string]interface{}, error)
- func (cp *ConnectionPool) HealthCheck(clusterID string) error
- func (cp *ConnectionPool) QueryRow(ctx context.Context, clusterID, query string, args ...interface{}) error
- func (cp *ConnectionPool) RemoveCluster(clusterID string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionConfig ¶
type ConnectionConfig struct {
Host string
Port int
User string
Password string
Database string
MaxConnections int
MinConnections int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
SSLMode string
}
ConnectionConfig holds database connection configuration
type ConnectionPool ¶
type ConnectionPool struct {
// contains filtered or unexported fields
}
ConnectionPool manages database connections
func NewConnectionPool ¶
func NewConnectionPool(log *logrus.Logger) *ConnectionPool
NewConnectionPool creates a new connection pool manager
func (*ConnectionPool) AddCluster ¶
func (cp *ConnectionPool) AddCluster(clusterID string, config ConnectionConfig) error
AddCluster adds a new cluster connection to the pool
func (*ConnectionPool) Close ¶
func (cp *ConnectionPool) Close()
Close closes all connections in the pool
func (*ConnectionPool) ExecuteQuery ¶
func (cp *ConnectionPool) ExecuteQuery(ctx context.Context, clusterID, query string, args ...interface{}) error
ExecuteQuery executes a query on a specific cluster Note: This is a simplified wrapper. For production use, implement proper row handling
func (*ConnectionPool) GetAllClusters ¶
func (cp *ConnectionPool) GetAllClusters() []string
GetAllClusters returns a list of all cluster IDs
func (*ConnectionPool) GetPool ¶
func (cp *ConnectionPool) GetPool(clusterID string) (*pgxpool.Pool, error)
GetPool returns the connection pool for a cluster
func (*ConnectionPool) GetPoolStats ¶
func (cp *ConnectionPool) GetPoolStats(clusterID string) (map[string]interface{}, error)
GetPoolStats returns statistics for a cluster's connection pool
func (*ConnectionPool) HealthCheck ¶
func (cp *ConnectionPool) HealthCheck(clusterID string) error
HealthCheck performs a health check on a cluster connection
func (*ConnectionPool) QueryRow ¶
func (cp *ConnectionPool) QueryRow(ctx context.Context, clusterID, query string, args ...interface{}) error
QueryRow executes a query that returns a single row
func (*ConnectionPool) RemoveCluster ¶
func (cp *ConnectionPool) RemoveCluster(clusterID string) error
RemoveCluster removes a cluster from the pool