Documentation ¶
Index ¶
- Variables
- type Balancer
- func (b *Balancer) Add(name string, c driver.Connector)
- func (b *Balancer) Connect(ctx context.Context) (driver.Conn, error)
- func (b *Balancer) ConnectorNames() []string
- func (b *Balancer) Driver() driver.Driver
- func (b *Balancer) Open(_ string) (driver.Conn, error)
- func (b *Balancer) OpenConnector(name string) (driver.Connector, error)
- func (b *Balancer) Remove(name string)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoConnectors = errors.New("lbsql: no available connectors")
ErrNoConnectors is returned when there are no connectors added to the balancer.
Functions ¶
This section is empty.
Types ¶
type Balancer ¶
type Balancer struct {
// contains filtered or unexported fields
}
Balancer is a driver.Connector that randomly picks between the connectors that have been added to it when establishing connections.
func (*Balancer) Connect ¶
Connect connects to a random driver.Connector. If the connection fails it retries all the available connectors until one succeeds, or the context is canceled.
func (*Balancer) ConnectorNames ¶
ConnectorNames returns a list of all the names of connectors currently in the balancer.
func (*Balancer) OpenConnector ¶
OpenConnector returns the balancer.
Click to show internal directories.
Click to hide internal directories.