Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDublicatedDataSource means that connStrings contains duplicated items ErrDublicatedDataSource = errors.New("duplicated data source") // ErrZeroDataSource means that an empty connStrings was passed ErrZeroDataSource = errors.New("data source must contain at least one item") )
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster represents a PostgreSQL cluster keeping track of a current master
func NewPostgreSQLCluster ¶
NewPostgreSQLCluster creates Cluster. Drivername can be specified, but must point to a PostgreSQL driver.
func (*Cluster) Close ¶
Close closes connections per each db contained in Cluster. An error fron each Close is collected.
func (*Cluster) DB ¶
DB returns *sql.DB suggested to be a master in the cluster. Current implementation checks master every 5 seconds. However the proper approach is to reelect a master after disconnection error.
func (*Cluster) ReElect ¶
func (c *Cluster) ReElect()
ReElect verifies if the current master is really master. New master will be elected if needed. This can be called after connections errors detection.
func (*Cluster) SetConnMaxLifetime ¶
SetConnMaxLifetime sets the maximum amount of time a connection may be reused for each memeber of a cluster
func (*Cluster) SetMaxIdleConns ¶
SetMaxIdleConns sets the maximum number of connections in the idle connection pool for each memeber of a cluster
func (*Cluster) SetMaxOpenConns ¶
SetMaxOpenConns sets the maximum number of open connections to the database for each memeber of a cluster