Documentation
¶
Index ¶
- func New(config map[string]interface{}) (interface{}, error)
- type Client
- func (c *Client) GetDb(master bool) *sql.DB
- func (c *Client) Init() error
- func (c *Client) SetDriver(driver string)
- func (c *Client) SetDsn(dsn string)
- func (c *Client) SetMaxConnTime(v string) error
- func (c *Client) SetMaxIdleConn(maxIdleConn int)
- func (c *Client) SetMaxOpenConn(maxOpenConn int)
- func (c *Client) SetSlaves(v []interface{})
- func (c *Client) SetSlowLogTime(v string) error
- func (c *Client) SetSqlLog(sqlLog bool)
- func (c *Client) SlowLogTime() time.Duration
- func (c *Client) SqlLog() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
DB client component, wrapper for database/sql, support read-write splitting, configuration: components:
db: driver: "mysql" dsn: "user:pass@tcp(127.0.0.1:3306)/db?charset=utf8&timeout=0.5s" slaves: ["slave1 dsn", "slave2 dsn"] maxIdleConn: 5 maxOpenConn: 10 sqlLog:false maxConnTime: "1h" slowLogTime: "100ms"
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) SetDsn ¶
SetDsn set master dsn, the dsn is driver specified, eg. dsn format for github.com/go-sql-driver/mysql is [username[:password]@][protocol[(address)]]/dbname[?param=value]
func (*Client) SetMaxConnTime ¶
SetMaxConnTime set conn life time, default is 1h
func (*Client) SetMaxIdleConn ¶
SetMaxIdleConn set max idle conn, default is 5
func (*Client) SetMaxOpenConn ¶
SetMaxOpenConn set max open conn, default is 0
func (*Client) SetSlowLogTime ¶
SetSlowTime set slow log time, default is 100ms
func (*Client) SlowLogTime ¶
Click to show internal directories.
Click to hide internal directories.