Documentation ¶
Index ¶
- Variables
- func NewClientTLSConfig(caPem, certPem, keyPem []byte, insecureSkipVerify bool, serverName string) *tls.Config
- type Conn
- func (c *Conn) Begin() error
- func (c *Conn) Close() error
- func (c *Conn) Commit() error
- func (c *Conn) Execute(command string, args ...interface{}) (*Result, error)
- func (c *Conn) ExecuteSelectStreaming(command string, result *Result, perRowCallback SelectPerRowCallback) error
- func (c *Conn) FieldList(table string, wildcard string) ([]*Field, error)
- func (c *Conn) GetCharset() string
- func (c *Conn) GetConnectionID() uint32
- func (c *Conn) GetDB() string
- func (c *Conn) HandleErrorPacket(data []byte) error
- func (c *Conn) HandleOKPacket(data []byte) *Result
- func (c *Conn) IsAutoCommit() bool
- func (c *Conn) IsInTransaction() bool
- func (c *Conn) Ping() error
- func (c *Conn) Prepare(query string) (*Stmt, error)
- func (c *Conn) ReadOKPacket() (*Result, error)
- func (c *Conn) Rollback() error
- func (c *Conn) SetAutoCommit() error
- func (c *Conn) SetCharset(charset string) error
- func (c *Conn) SetTLSConfig(config *tls.Config)
- func (c *Conn) UseDB(dbName string) error
- func (c *Conn) UseSSL(insecureSkipVerify bool)
- type Connection
- type ConnectionStats
- type LogFunc
- type Pool
- type SelectPerRowCallback
- type Stmt
- type Timestamp
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // MaxIdleTimeoutWithoutPing - If the connection has been idle for more than this time, // then ping will be performed before use to check if it alive MaxIdleTimeoutWithoutPing = 10 * time.Second // DefaultIdleTimeout - If the connection has been idle for more than this time, // we can close it (but we should remember about Pool.minAlive) DefaultIdleTimeout = 30 * time.Second // MaxNewConnectionAtOnce - If we need to create new connections, // then we will create no more than this number of connections at a time. // This restriction will be ignored on pool initialization. MaxNewConnectionAtOnce = 5 )
Functions ¶
Types ¶
type Conn ¶
func Connect ¶
func Connect(addr string, user string, password string, dbName string, options ...func(*Conn)) (*Conn, error)
Connect to a MySQL server, addr can be ip:port, or a unix socket domain like /var/sock. Accepts a series of configuration functions as a variadic argument.
func (*Conn) ExecuteSelectStreaming ¶
func (c *Conn) ExecuteSelectStreaming(command string, result *Result, perRowCallback SelectPerRowCallback) error
ExecuteSelectStreaming will call perRowCallback for every row in resultset
WITHOUT saving any row data to Result.{Values/RawPkg/RowDatas} fields.
ExecuteSelectStreaming should be used only for SELECT queries with a large response resultset for memory preserving.
Example:
var result mysql.Result conn.ExecuteSelectStreaming(`SELECT ... LIMIT 100500`, &result, func(row []mysql.FieldValue) error { // Use the row as you want. // You must not save FieldValue.AsString() value after this callback is done. Copy it if you need. return nil })
func (*Conn) GetCharset ¶
func (*Conn) GetConnectionID ¶
func (*Conn) HandleErrorPacket ¶
func (*Conn) HandleOKPacket ¶
func (*Conn) IsAutoCommit ¶
func (*Conn) IsInTransaction ¶
func (*Conn) ReadOKPacket ¶
func (*Conn) SetAutoCommit ¶
func (*Conn) SetCharset ¶
func (*Conn) SetTLSConfig ¶
SetTLSConfig: use user-specified TLS config pass to options when connect
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
type ConnectionStats ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func NewPool ¶
func NewPool( logFunc LogFunc, minAlive int, maxAlive int, maxIdle int, addr string, user string, password string, dbName string, options ...func(conn *Conn), ) *Pool
NewPool initializes new connection pool and uses params: addr, user, password, dbName and options.
minAlive specifies the minimum number of open connections that the pool will try to maintain. maxAlive specifies the maximum number of open connections (for internal reasons, may be greater by 1 inside newConnectionProducer). maxIdle specifies the maximum number of idle connections (see DefaultIdleTimeout).
func (*Pool) GetStats ¶
func (pool *Pool) GetStats(stats *ConnectionStats)
type SelectPerRowCallback ¶
type SelectPerRowCallback func(row []FieldValue) error
This function will be called for every row in resultset from ExecuteSelectStreaming.
Click to show internal directories.
Click to hide internal directories.