Documentation ¶
Index ¶
- type Balancer
- func (b *Balancer) Close() error
- func (b *Balancer) Get(i interface{}, keys ...interface{}) (interface{}, error)
- func (b *Balancer) GetAllDbs() []*gorp.DbMap
- func (b *Balancer) Master() *gorp.DbMap
- func (b *Balancer) MasterCanRead(read bool)
- func (b *Balancer) Ping() error
- func (b *Balancer) Prepare(query string) (Stmt, error)
- func (b *Balancer) Replica() *gorp.DbMap
- func (b *Balancer) Select(i interface{}, query string, args ...interface{}) ([]interface{}, error)
- func (b *Balancer) SelectFloat(query string, args ...interface{}) (float64, error)
- func (b *Balancer) SelectInt(query string, args ...interface{}) (int64, error)
- func (b *Balancer) SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error)
- func (b *Balancer) SelectNullInt(query string, args ...interface{}) (sql.NullInt64, error)
- func (b *Balancer) SelectNullStr(query string, args ...interface{}) (sql.NullString, error)
- func (b *Balancer) SelectOne(holder interface{}, query string, args ...interface{}) error
- func (b *Balancer) SelectStr(query string, args ...interface{}) (string, error)
- func (b *Balancer) SetConnMaxLifetime(d time.Duration)
- func (b *Balancer) SetMaxIdleConns(n int)
- func (b *Balancer) SetMaxOpenConns(n int)
- func (b *Balancer) TraceOff()
- func (b *Balancer) TraceOn(prefix string, logger gorp.GorpLogger)
- type Stmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Balancer ¶
Balancer embeds multiple connections to physical db and automatically distributes queries with a round-robin scheduling around a master/replica replication. Write queries are executed by the Master. Read queries(SELECTs) are executed by the replicas.
func NewBalancer ¶
NewBalancer opens a connection to each physical db. dataSourceNames must be a semi-comma separated list of DSNs with the first one being used as the master and the rest as replicas.
func (*Balancer) GetAllDbs ¶
GetAllDbs returns each underlying physical database, the first one is the master
func (*Balancer) MasterCanRead ¶
MasterCanRead adds the master physical database to the replicas list if read==true so that the master can perform WRITE queries AND READ queries .
func (*Balancer) Ping ¶
Ping verifies if a connection to each physical database is still alive, establishing a connection if necessary.
func (*Balancer) Prepare ¶
Prepare creates a prepared statement for later queries or executions on each physical database. Multiple queries or executions may be run concurrently from the returned statement. This is equivalent to running: Prepare() using database/sql
func (*Balancer) SelectFloat ¶
SelectFloat https://godoc.org/gopkg.in/gorp.v2#DbMap.SelectFloat
func (*Balancer) SelectInt ¶
SelectInt https://godoc.org/gopkg.in/gorp.v2#DbMap.SelectInt
func (*Balancer) SelectNullFloat ¶
func (b *Balancer) SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error)
SelectNullFloat https://godoc.org/gopkg.in/gorp.v2#DbMap.SelectNullFloat
func (*Balancer) SelectNullInt ¶
SelectNullInt https://godoc.org/gopkg.in/gorp.v2#DbMap.SelectNullInt
func (*Balancer) SelectNullStr ¶
func (b *Balancer) SelectNullStr(query string, args ...interface{}) (sql.NullString, error)
SelectNullStr https://godoc.org/gopkg.in/gorp.v2#DbMap.SelectNullStr
func (*Balancer) SelectOne ¶
SelectOne https://godoc.org/gopkg.in/gorp.v2#DbMap.SelectOne
func (*Balancer) SelectStr ¶
SelectStr https://godoc.org/gopkg.in/gorp.v2#DbMap.SelectStr
func (*Balancer) SetConnMaxLifetime ¶
SetConnMaxLifetime sets the maximum amount of time a connection may be reused. Expired connections may be closed lazily before reuse. If d <= 0, connections are reused forever.
func (*Balancer) SetMaxIdleConns ¶
SetMaxIdleConns sets the maximum number of connections If MaxOpenConns is greater than 0 but less than the new MaxIdleConns then the new MaxIdleConns will be reduced to match the MaxOpenConns limit If n <= 0, no idle connections are retained.
func (*Balancer) SetMaxOpenConns ¶
SetMaxOpenConns sets the maximum number of open connections If MaxIdleConns is greater than 0 and the new MaxOpenConns is less than MaxIdleConns, then MaxIdleConns will be reduced to match the new MaxOpenConns limit. If n <= 0, then there is no limit on the number of open connections. The default is 0 (unlimited).