mymysql: github.com/ziutek/mymysql/autorc Index | Files

package autorc

import "github.com/ziutek/mymysql/autorc"

Package autorc provides an auto reconnect interface for MyMySQL.

Index

Package Files

autorecon.go

func IsNetErr Uses

func IsNetErr(err error) bool

IsNetErr returns true if error is network error or UnexpectedEOF.

type Conn Uses

type Conn struct {
    Raw mysql.Conn
    // Maximum reconnect retries.
    // Default is 7 which means 1+2+3+4+5+6+7 = 28 seconds before return error
    // (if waiting for error takes no time).
    MaxRetries int

    // Debug logging. You may change it at any time.
    Debug bool
}

Conn is an autoreconnecting connection type.

func New Uses

func New(proto, laddr, raddr, user, passwd string, db ...string) *Conn

New creates a new autoreconnecting connection.

func NewFromCF Uses

func NewFromCF(cfgFile string) (*Conn, map[string]string, error)

NewFromCF creates a new autoreconnecting connection from config file. Returns connection handler and map containing unknown options.

func (*Conn) Begin Uses

func (c *Conn) Begin(f func(mysql.Transaction, ...interface{}) error, args ...interface{}) error

Begin starts a transaction and calls f to complete it. If f returns an error and IsNetErr(error) == true it reconnects and calls f up to MaxRetries times. If error is of type *mysql.Error it tries to rollback the transaction.

func (*Conn) Clone Uses

func (c *Conn) Clone() *Conn

Clone makes a copy of the connection.

func (*Conn) Escape Uses

func (c *Conn) Escape(s string) string

Escape is an automatic connect/reconnect/repeat version of mysql.Conn.Escape.

func (*Conn) Prepare Uses

func (c *Conn) Prepare(sql string) (*Stmt, error)

Prepare is an automatic connect/reconnect/repeat version of mysql.Conn.Prepare.

func (*Conn) PrepareOnce Uses

func (c *Conn) PrepareOnce(s *Stmt, sql string) error

PrepareOnce prepares a statement if it wasn't prepared before.

func (*Conn) Query Uses

func (c *Conn) Query(sql string, params ...interface{}) (rows []mysql.Row, res mysql.Result, err error)

Query is an automatic connect/reconnect/repeat version of mysql.Conn.Query.

func (*Conn) QueryFirst Uses

func (c *Conn) QueryFirst(sql string, params ...interface{}) (row mysql.Row, res mysql.Result, err error)

QueryFirst is an automatic connect/reconnect/repeat version of mysql.Conn.QueryFirst.

func (*Conn) QueryLast Uses

func (c *Conn) QueryLast(sql string, params ...interface{}) (row mysql.Row, res mysql.Result, err error)

QueryLast is an automatic connect/reconnect/repeat version of mysql.Conn.QueryLast.

func (*Conn) Reconnect Uses

func (c *Conn) Reconnect() (err error)

Reconnect tries to reconnect the connection up to MaxRetries times.

func (*Conn) Register Uses

func (c *Conn) Register(sql string)

func (*Conn) SetMaxPktSize Uses

func (c *Conn) SetMaxPktSize(new_size int) int

func (*Conn) SetTimeout Uses

func (c *Conn) SetTimeout(timeout time.Duration)

SetTimeout sets a timeout for underlying mysql.Conn connection.

func (*Conn) Use Uses

func (c *Conn) Use(dbname string) (err error)

Use is an automatic connect/reconnect/repeat version of mysql.Conn.Use.

type Stmt Uses

type Stmt struct {
    Raw mysql.Stmt
    // contains filtered or unexported fields
}

Stmt contains mysql.Stmt and autoteconnecting connection.

func (*Stmt) Bind Uses

func (s *Stmt) Bind(params ...interface{})

Bind is an automatic connect/reconnect/repeat version of mysql.Stmt.Bind.

func (*Stmt) Exec Uses

func (s *Stmt) Exec(params ...interface{}) (rows []mysql.Row, res mysql.Result, err error)

Exec is an automatic connect/reconnect/repeat version of mysql.Stmt.Exec.

func (*Stmt) ExecFirst Uses

func (s *Stmt) ExecFirst(params ...interface{}) (row mysql.Row, res mysql.Result, err error)

ExecFirst is an automatic connect/reconnect/repeat version of mysql.Stmt.ExecFirst.

func (*Stmt) ExecLast Uses

func (s *Stmt) ExecLast(params ...interface{}) (row mysql.Row, res mysql.Result, err error)

ExecLast is an automatic connect/reconnect/repeat version of mysql.Stmt.ExecLast.

Package autorc imports 5 packages (graph) and is imported by 22 packages. Updated 2017-03-28. Refresh now. Tools for package owners.